Linux C 程序 两变量值交换(FIVE)

时间:2022-07-02 13:04:27

example:
1.运算符:

 #include<stdio.h>
 int main(){
     int a , b , c ,d ;
     a = ;
     b = a++;//先赋值给b,a再自增
     c = ++a;//先加后赋值给c
     d = *a++;//相当于 d=(10*a),a=a+1
     printf("b,c,d :%d,%d,%d",b,c,d);
 }
 output:
 b ,c ,d ,,

2.两种方法实现交换两个变量的值

 方法-:中间变量
     ,b=,temp;
     temp = a;
     a = b ;
     b = temp;
 方法二:
   ,b=;
   a = a + b;
   b = a - b;
   a = a - b;