• January 15th, 2014, 12:49 AM
Linda95
import java.swing.*;
import java.math.*;
public class KonvertoMatricenNeVektor {

public static void main(String[] args)
{int a =new Integer (JOptionPane.showInputDialog("Jepni numrin e rreshtave")).intValue();
int b= new Integer(JOptionPane.showInputDialog("Jepni numrin e shtyllave")).intValue();
int matrica [][]=new int [a][b];
for(int i=0; i<b; i++)
{for(int j=0; j<a; j++)
matrica[i][j]=(int) ((int) Math.random()*10);
vektor(matrica);}}
public static void vektor(int[][]m)
{int rr=0;
int sh=0;
for(int i=0;i<m.length;i++)
{ rr+=1;
for(int j=0;j<m[i].length;j++)
sh+=1;}
int vektor[]=new int[rr*sh];
int k=0;
for(int i=0; i<m[i].length;i++)
{k+=1;
for(int j=0;j<m.length;j++)
{vektor[k]=m[i][j];
k+=1;}
for(int a=0;a<vektor.length;a++)
System.out.println(vektor[a]);}

}

}
• January 15th, 2014, 01:14 AM
StaticHS
Announcements - What's Wrong With My Code?
• January 15th, 2014, 05:06 AM
GregBrannon
```import java.swing.*; import java.math.*; public class KonvertoMatricenNeVektor {   public static void main(String[] args) {int a =new Integer (JOptionPane.showInputDialog("Jepni numrin e rreshtave")).intValue(); int b= new Integer(JOptionPane.showInputDialog("Jepni numrin e shtyllave")).intValue(); int matrica [][]=new int [a][b]; for(int i=0; i<b; i++) {for(int j=0; j<a; j++) matrica[i][j]=(int) ((int) Math.random()*10); vektor(matrica);}} public static void vektor(int[][]m) {int rr=0; int sh=0; for(int i=0;i<m.length;i++) { rr+=1; for(int j=0;j<m[i].length;j++) sh+=1;} int vektor[]=new int[rr*sh]; int k=0; for(int i=0; i<m[i].length;i++) {k+=1; for(int j=0;j<m.length;j++) {vektor[k]=m[i][j]; k+=1;} for(int a=0;a<vektor.length;a++) System.out.println(vektor[a]);}   }     }```