第一章课后习题
5.编写一个c程序,运行时输出以下图形:
6. 编写一个程序,运行时输入a,b,c三个值,输出其中值最大者。
5.编写一个c程序,运行时输出以下图形:
*****
*****
*****
void print_star(){
// 逐行打印
for (int i = 0; i < 4; i ++){
// 打印空格
for (int j = 0; j < i*2; j++)
printf(" ");
printf("****\n");
}
}
6. 编写一个程序,运行时输入a,b,c三个值,输出其中值最大者。
void get_max_in_3(){
int a, b, c;
int max; //最大整数
scanf("%d %d %d", &a, &b, &c);
//a b中的较大的数存放在max_ab
int max_ab = compare_two(a, b);
//比较max_ab 与 c
max = compare_two(max_ab, c);
printf("the max integer is:%d\n", max);
}
//返回两个整数中较大的那一个
int compare_two(int x, int y){
if (x >= y)
return x;
else
return y;
}
MarkDown输入空格:
https://blog.csdn.net/u012150360/article/details/83789466