代码1-11
1 #include2 int main() 3 { 4 int a,b,n,m; 5 scanf("%d%d",&n,&m); 6 a=(4*n-m)/2; 7 b=n-a; 8 if(n%2==1||a<0||b<0) 9 printf("No answer\n");10 else11 printf("%d %d",a,b);12 return 0;13 }
程序1-12
1 #include2 int main() 3 { 4 int a,b,c; 5 scanf("%d%d%d",&a,&b,&c); 6 if(a
程序1-13 三整数排序
1 #include2 int main() 3 { 4 int a,b,c; 5 scanf("%d%d%d",&a,&b,&c); 6 if(a<=b&&b<=c)printf("%d %d %d",a,b,c); 7 else if(a<=c&&c<=b)printf("%d %d %d",a,c,b); 8 else if(b<=a&&a<=c)printf("%d %d %d",b,a,c); 9 else if(b<=c&&c<=a)printf("%d %d %d",b,c,a);10 else if(c<=a&&a<=b)printf("%d %d %d",c,a,b);11 else if(c<=b&&b<=a)printf("%d %d %d",c,b,a);12 return 0;13 }
程序1-14 三整数排序(3)
1 #include2 int main() 3 { 4 int a,b,c,t; 5 scanf("%d%d%d",&a,&b,&c); 6 if(a>b){t=a;a=b;b=t;} 7 if(a>c){t=a;a=c;c=t;} 8 if(b>c){t=b;b=c;c=t;} 9 printf("%d %d %d",a,b,c);10 return 0;11 }