zoukankan      html  css  js  c++  java
  • c语言 511

     1、

    #include <stdio.h>
    
    int main(void)
    {
        int i, j, a[6][2];
        for(i = 0; i < 6; i++)
        {
            for(j = 0; j < 2; j++)
            {
                printf("a[%d][%d] = ", i, j); scanf("%d", &a[i][j]); 
            }
        }
        puts("show the matrix form of 6 row 2 col array.");
        for(i = 0; i < 6; i++)
        {
            for(j = 0; j < 2; j++)
            {
                printf("%4d", a[i][j]);
            }
            putchar('\n');
        }
        
        int sumchi = 0, summath =0;
        for(i = 0; i < 6; i++)
        {
            for(j = 0; j < 2; j++)
            {
                if( j == 0)
                    sumchi += a[i][j];
                else
                    summath += a[i][j];
            }
        }
        printf("sumchi = %d\n", sumchi);
        printf("summath = %d\n", summath);
        
        int c[6]= {0};
        for(i = 0; i < 6; i++)
        {
            for(j = 0; j < 2; j++)
            {
                c[i] += a[i][j];    
            }
        }
        
        for(i = 0; i < 6; i++)
        {
            printf("the sum = %d  the mean = %.2f\n", c[i], (double)c[i] / 2);
        }
        
        return 0;
    }

  • 相关阅读:
    上传文件事件并校验:event.target.files && event.target.files[0]
    深浅拷贝
    Git学习
    Flex弹性布局
    hive
    222
    错误总结
    Redis小结2
    spark小结
    kafka详解
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14723642.html
Copyright © 2011-2022 走看看