求三个数的和及平均值
```c
include
int main() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int sum = a + b + c;
float average = (float)sum / 3.0;
printf("和: %d\n", sum);
printf("平均值: %.2f\n", average);
return 0;
}
```
比较三个数的大小并输出
```c
include
int main() {
int a, b, c;
printf("请输入三个数:\n");
scanf("%d%d%d", &a, &b, &c);
if (a > b) {
int temp = a;
a = b;
b = temp;
}
if (a > c) {
int temp = a;
a = c;
c = temp;
}
if (b > c) {
int temp = b;
b = c;
c = temp;
}
printf("从大到小为: %d %d %d\n", a, b, c);
return 0;
}
```
输入三个数并按从小到大排序
```c
include
int main() {
int a, b, c;
printf("请输入三个整数:\n");
scanf("%d %d %d", &a, &b, &c);
if (a > b) {
int temp = a;
a = b;
b = temp;
}
if (a > c) {
int temp = a;
a = c;
c = temp;
}
if (b > c) {
int temp = b;
b = c;
c = temp;
}
printf("三个数从小到大排序: %d %d %d\n", a, b, c);
return 0;
}
```
使用临时变量交换三个数
```c
include
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}
int main() {
int a, b, c;
printf("请输入三个数:\n");
scanf("%d%d%d", &a, &b, &c);
swap(&a, &b);
swap(&a, &c);
swap(&b, &c);
printf("从大到小为: %d %d %d\n", a, b, c);
return 0;
}
```
这些程序涵盖了从简单的求和、比较大小到更复杂的排序和交换操作。你可以根据具体需求选择合适的程序进行参考和修改。