ZKX's LAB

输入2个整数 并交换2个变量的值 编程,输入两个整数送给变量a和b,输出它们的值,然后交换变量a和b的

2020-07-19知识8

输入两个整形变量,将两个变量的值互换后输出 方法/步骤 1 整体代码如下 include void main() { int a,b,x;printf(\"请输入两个整形变量的值:\");scanf(\"%d,%d\",&a,&b);x=a;a=b;b=x;printf(\"a=d,b=d\\n\",a,b);。c语言:先定义两个整数变量,然后输入两个值,再交换这两个变量的值,最后输出交换后的新值 include main(){ int a,b,x;scanf(\"%d%d\",&a,&b);x=a;a=b;b=x;printf(\"a=d,b=d\\n\",a,b);}1计算3个整数的乘积,2…交换两个变量的值 /三个数的乘积includeint main(){int x,y,z,result;printf(\"请输入三个整数,用逗号分开:\");scanf(\"%d,%d,%d\",&x,&y,&z);result=x*y*z;printf(\"乘积等于:%d\\n\",result);}交换两个变量includeint main(){int x,y,temp;printf(\"Please Enter 2 number:\");scanf(\"%d%d\",&x,&y);temp=x;x=y;y=temp;还可以使用下面的方法进行交换:x^=y;y^=x;x^=y;printf(\"%d%d\",x,y);}. 从键盘输入两个整数保存到两个变量中,并把两个变量的值交换,并打印输出每个变量的值。 看你想怎样2113常规的5261:incluldeincludeincludeincludeusing namespace std;int main(){int a,b;cin>;>;a>;>;b;int t=a;a=bb=t;cout;return 0;}装逼的:incluldeincludeincludeincludeusing namespace std;int main(){int a,b;cin>;>;a>;>;b;a=a+b;b=a-b;a=a-b;cout;return 0;}偷懒的4102:incluldeincludeincludeincludeusing namespace std;int main(){int a,b;cin>;>;a>;>;b;swap(a,b);cout;return 0;}作弊1653的:incluldeincludeincludeincludeusing namespace std;int main(){int a,b;cin>;>;a>;>;b;swap(a,b);cout;return 0;}

#scanf#printf#变量

qrcode
访问手机版