#include<stdio.h>//求十个整数中最大的值
#include<stdlib.h>
int main(){
int arr[10] = { 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int max = arr[0];
int i = 0;
for (i = 0; i < 10; i++){
if (max>arr[i]){
continue;
}
else{
max = arr[i];
}
}
printf("max=%d\n", max);
system("pause");
return 0;
}
//给的两个整形变量的值,将两个值的内容进行交换。
#include <stdio.h>
void main(){
int a = 1;
int b = 2;
printf("a=%d\n", b);
printf("b=%d\n", a);
system("pause");
return 0;
}
#include<stdio.h>//求两个数之间是的最大公约
int hcf(int x, int y){
int t;
if (x < y){
t = x;
x = y;
y = t;
}
while ((t = x%y) != 0){
x = y;
y = t;
}
return y;
}
int lcf(int x, int y, int m)
{
return x*y / m;
}
int main() {
int hcf(int, int);
int lcf(int, int, int);
int x, y, h, l;
printf("请输入两个数\n");
scanf("%d%d", &x, &y);
h = hcf(x, y);
l = lcf(x, y, h);
printf("最大公约数:h=%d\n最小公倍数为:l=%d\n",h, l);
return 0;
}