首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >不使用第3个变量,实现两个数的对调

不使用第3个变量,实现两个数的对调

作者头像
小Bob来啦
发布2020-12-15 09:42:55
发布2020-12-15 09:42:55
1.5K0
举报

Youth is a beautiful but also a time to go, it is the beginning of all the bright and happy in the future.

青少年是一个美好而又是一去不可再得的时期,是将来一切光明和幸福的开端。

任务:不用第三个变量,实现将两个数进行对调的操作。

输入:3 4

输出:

a=3 b=4

a=4 b=3

源代码:

代码语言:javascript
复制
#include<stdio.h>
  int main(void)
{  
    int a,b;
      scanf("%d%d",&a,&b); 
      printf("a=%d b=%d\n",a,b);
    printf("a=%d  b=%d\n",b,a);  
       return 0;
  }

运行结果:

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-04-26,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档