1. 程式人生 > >小試牛刀9.19

小試牛刀9.19

sca mat tdi nbsp math.h ret %d while printf

1 #include<stdio.h> #include<stdlib.h> int main() { int a = 1; int b = 2; a = a + b; b = a - b; a = a - b; printf("a=%d\n", a); printf("b=%d\n", b); system("pause"); return 0;

} 2.(1) #include<stdio.h> #include<stdlib.h> int main() { int a = 1; int b = 2; int c = 0; c = a; a = b; b = c; printf("a=%d\n", a); printf("b=%d\n", b); system("pause"); return 0;

2(2). #include<stdio.h> #include<stdlib.h> int main() { int a=1; int b=2; a=a^b; b=b^a; a=a^b; printf("a=%d\n",a); printf("b=%d",b); system("pause"); return 0; }

3. #include<stdio.h> #include<stdlib.h> #include<math.h>

int main()

{

int i =0,a[10];

for(i = 0; i < 10; i++)

scanf("%d",&a[i]);

int max = a[0];

for(i = 0; i < 10; i++)

if(max < a[i])

max = a[i];

printf("%d",max);

system("pause"); return 0;}

4 #include<stdio.h> #include<stdlib.h> int main() { int a,b,c,t; scanf("%d %d %d",&a,&b,&c); if(a<b) { t=b; b=a; a=t; } if(a<c) { t=a; a=c; c=t; } if(c>b) { t=b; b=c; c=t; } printf("%d %d %d",a,b,c);

system("pause"); return 0; } 5. #include<stdio.h> #include<stdlib.h> int main() { int a,b,c; scanf("%d %d",&a,&b); while(a%b) { c=a%b; a=b; b=c;} printf("%d",b); system("puase"); return 0; }

小試牛刀9.19