兩個變數的值,做交換的動作
(高顯忠, sjgau4311@gmail.com, 2011-07-19 20:47)
1樓
#if 0
a= 385, b= 270
請按任意鍵繼續 . . .
a= 270, b= 385
c= 1195
請按任意鍵繼續 . . .
#endif
// ----------------------------------------------
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
// ----------------------------------------------
int main()
{
int a, b, c, i;
// srand(time(NULL));
srand(0x410);
for (i=1;i<=300;i++) {
a= rand();
}
a= rand()%1000;
b= rand()%1000;
printf("a= %d, b= %d \n", a, b);
system("pause");
int temp;
// a --> temp
temp= a;
a= b;
b= temp;
c=3*a + b;
printf("a= %d, b= %d \n c= %d \n", a, b, c);
system("pause");
return 0;
}// end of main()