二维数组的应用;

package se;
import java.util.Scanner;
import java.util.Random;
public class sdfs {
    public static void main(String[] args) {
        int sale[][] = new int [10][10];
        int col[]=new int[10];
        int row[]=new int[10];
        for(int i=1;i<=5;i++)
        {
            sale[0][i]=i;
        }
        for(int j=1;j<=4;j++)
        {
            sale[j][0]=j;
        }
        for(int i=1;i<=4;i++)
        {   
            row[i]=0;
            for(int j=1;j<=5;j++)
            {
                Random random = new Random();
                int t=random.nextInt(100);
                sale[i][j]=t;
                row[i]+=t;
            }

        }
        for(int j=1;j<=5;j++)
        {
            col[j]=0;
            for(int i=1;i<=4;i++)
            {
                col[j]+=sale[i][j];
            }
        }
        for(int i=0;i<=4;i++)
        {
            for(int j=0;j<=5;j++)
            {
                System.out.printf("%d\t",sale[i][j]);
            }
            if(i==0)
            System.out.printf("total\t");
            else
            {
                System.out.printf("%d\t", row[i]);
            }
            System.out.printf("\n");
        }
        for(int i=0;i<=5;i++)
        {
            if(i==0)
                System.out.printf("total\t");
            else
            {
                System.out.printf("%d\t", col[i]);
            }
        }
        System.out.printf("\n");
    }
}