求教该怎么退出循环
原题是给定两个整数A和B,其表示形式是:从个位开始,每三位数用逗号","隔开。
现在请计算A+B的结果,并以正常形式输出。
输入:
输入包含多组数据数据,每组数据占一行,由两个整数A和B组成(-10^9 < A,B < 10^9)。
输出:
请计算A+B的结果,并以正常形式输出,每组数据占一行。
这个是我写的,不知道退出循环的条件该怎么写,求指教
程序代码:#include <stdio.h>
#include <string.h>
#include <ctype.h>
long pows(int x);
long scanft(void);
int main(void)
{
long a,b;
a=scanft();
b=scanft();
while(1)
{
printf("%ld\n",a+b);
a=scanft();
b=scanft();
}
return 0;
}
long pows(int x)
{
int a,n=10;
if(x==0)
n=1;
else for(a=1;a<x;a++)
n*=10;
return n;
}
long scanft(void)
{
char num[14];
long n=0;
int a,b=0;
scanf("%s",num);
a=strlen(num);
while(a-->0)
{
if(isdigit(num[a]))
n+=(num[a]-'0')*pows(b++);
}
if(num[0]=='-')
n=-n;
return n;
}







