题目:输出差值的绝对值。
分析:简单题。
注意:数据类型要用long long、不要使用abs()。
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
long long a,b;
while ( scanf("%lld%lld",&a,&b) != EOF )
if ( a > b )
printf("%d\n",a-b);
else printf("%d\n",b-a);
return 0;
}

本文介绍了一个简单的C语言程序,用于计算并输出两个长整型数值之间的差值的绝对值。该程序通过比较输入的两个数值大小来决定输出的顺序,确保了结果总是正值,并且避免了使用内置的abs()函数。
497

被折叠的 条评论
为什么被折叠?



