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

    1、

    #include <stdio.h>
    
    int main(void)
    {
        int i, j, a[6][2], b[2] = {0}, c[6] = {0};
        puts("please input the elements of array a.");
        for(i = 0; i < 6; i++)
        {
            for(j = 0; j < 2; j++)
            {
                printf("a[%d][%d] = ", i, j); scanf("%d", &a[i][j]);
            }
        }
        puts("\nshow the matrix form of array a.");
        for(i = 0; i < 6; i++)
        {
            for(j = 0; j < 2; j++)
            {
                printf("%4d", a[i][j]);
            }
            putchar('\n');
        }
        putchar('\n');
        for(i = 0; i < 2; i++)
        {
            for(j = 0; j < 6; j++)
            {
                b[i] += a[j][i];
            }
            printf("sum majorNO.%d: %d, mean: %.2f\n", i + 1, b[i], (double)b[i] / 6);
        }
        
        putchar('\n');
        for(i = 0; i < 6; i++)
        {
            for(j = 0; j < 2; j++)
            {
                c[i] += a[i][j];
            }
            printf("sum student.NO.%d: %d, mean: %.2f\n", i + 1, c[i], (double)c[i] / 2);
        }
        
        return 0;
    }

  • 相关阅读:
    Python调用C++的DLL
    Go-map
    Go-切片
    Go-数组
    Go-流程控制
    Go-运算符
    Go-变量和常量
    Go-VS Code配置Go语言开发环境
    Go-跨平台编译
    Go-从零开始搭建Go语言开发环境
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14727279.html
Copyright © 2011-2022 走看看