+ 2
Program to generate diagonal elements as 1
import java.io.*; public class sample{ public static void main(String args[])throws IOException { BufferedReader br =new BufferedReader(new InputStreamReader(System.in)); int n,m; n=Integer.parseInt(br.readLine()); m=Integer.parseInt(br.readLine()); int a[][]=new int[n][m]; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if(i==j) { a[i][j]=1; System.out.print(""+a[i][j]); } else { a[i][j]=0;
1 Réponse
+ 11
You published this code at the playground... Maybe a link to it would have been more useful than pasting the code here ^^
But I liked your code.