UVA 10055
计算士兵数差值,即大减小,可以用绝对值,也可以先判断大小,再做运算
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<stdio.h> 2 int main() 3 { 4 int a,b,t; 5 while(scanf("%d%d",&a,&b)!=EOF) 6 { 7 if(a>b) 8 { 9 t=a; 10 a=b; 11 b=t; 12 } 13 printf("%d\n",b-a); 14 } 15 return 0; 16 }
计算士兵数差值,即大减小,可以用绝对值,也可以先判断大小,再做运算
1 #include<stdio.h> 2 int main() 3 { 4 int a,b,t; 5 while(scanf("%d%d",&a,&b)!=EOF) 6 { 7 if(a>b) 8 { 9 t=a; 10 a=b; 11 b=t; 12 } 13 printf("%d\n",b-a); 14 } 15 return 0; 16 }