在这里插入代码//交换两个整型变量的值
#include <stdio.h>//用一个中间量
int a = 9;
int b = 8;
int c;
int main() {
c = b; b = a; a = c;
printf("a=%d\nb=%d", a, b);
system("pause");
}
//
//交换两个整型变量的值
#include <stdio.h>// 看成坐标轴,
int a = 9;
int b = 8;
int main( ) {
b = a - b;//求两点之间的距离
a = a - b;//坐标减去距离的到另外一个数字
b = a + b;//一个数字加上坐标等于另外一个数字
printf("a=%d\tb=%d", a, b);
system("pause");
return 0;
}
//求十个整数中最大的值
#include<stdio.h>// ,
int a[ 10 ] = { 4,8,98,5,9,45,44,4,7,48 };
int main( ) {
int i = 0;
int max = a[0];
for (i = 0; i <= 9; i++)//用循环控制数组下标,相邻比较,交换位置
{
if (max < a[i]){
max = a[i];
}
}
printf("%d",max);
system("pause");
return 0;
}
07-21
07-21
07-21
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交