C语言12.6

68 阅读1分钟
#include <stdio.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

void getSum(int n){
    int sum = 0;
    for(int i = 1; i <= n; i++){
        if(i % 2 == 0){
            sum += i;
        }
    }
    printf("1-n的偶数和为%d", sum);
}

void printfFunc1(int n){
    printf("\n");
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= i; j++){
            printf("%d * %d = %-5d", j, i, i * j);
        }
        printf("\n");
    }
}
void printFunc2(int a, int b, int c){
    int max = a;
    
    if (b > max) max = b;
    
    if (c > max) max = c;
    
    printf("最大值:%d\n", max);
}
int main() {
    getSum(4);
    printfFunc1(9);
    printFunc2(1,2,3)
    return 0;
}

上课笔记以及课下任务