#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
//1.输入三个数,求最大值
//c语言的几种方法
int main()
{
int a, b, c;
scanf_s("%d%d%d", &a, &b, &c);
int max;
max = a;
if (b > max) max = b;
if (c > max) max = c;
printf("最大值为:%d\n", max);
system("pause");
return 0;
}
int main()
{
int a, b, c;
scanf_s("%d%d%d", &a, &b, &c);
a = a > b ? a : b;
a = a > c ? a : c;
printf("最大值为:%d\n", a);
system("pause");
return 0;
}
int main()
{
int a, b, c; scanf_s("%d%d%d", &a, &b, &c);
if (a > b)
{
if (a > c)
{
printf("最大值为:%d\n", a);
}
else
{
printf("最大值为:%d\n", c);
}
}
else
{
if (b > c)
{
printf("最大值为:%d\n", b);
}
else
{
printf("最大值为:%d\n", c);
}
}
system("pause");
return 0;
}
//2.两个变量交换值的方法
//C语言
int main()
{
int a,b;
scanf_s("%d%d", &a, &b);
int temp;
temp = a;
a = b;
b = temp;
printf("a=%d,b=%d\n", a, b);
system("pause");
return 0;
}
int main()
{
int a, b;
scanf_s("%d%d", &a, &b);
a = a + b;
b = a - b;
a = a - b;
printf("a=%d,b=%d\n", a, b);
system("pause");
return 0;
}
int main()
{
int a, b;
scanf_s("%d%d", &a, &b);
a = a ^ b;
b = a ^ b;
a = a ^ b;
printf("a=%d,b=%d\n", a, b);
system("pause");
return 0;
}
//C++中只需要将上面程序的的输入输出改为输入(cin>>)和输出(cout<<)就可以了
|