int a[11];
int num = 0;
int n = 0;
int m = 0;
int yin = 1;
char temp;
char *b = new char[5];//以字符形式输入的各位数字保存在这里
while(cin.get(temp) && temp != '\n')
{
if((temp >= '1') && (temp <= '9'))
{
b[m] = temp;
m++;
}
else if(temp = ',')//每次遇到‘,’计算一次数字,并保存在int数组中
{
b[m] = '\0';
while(m != 0)
{
num += (b[m-1] - '0') * yin;
yin *= 10;
m--;
}
a[n] = num;
n++;
num = 0;
yin = 1;
delete b;
char *b = new char[5];
}
}
//最后一次,由于最后一个数字没有‘,’号,故需要在计算一次
b[m] = '\0';while(m != 0)
{
num += (b[m-1] - '0') * yin;
yin *= 10;
m--;
}
a[n] = num;
n++;
cout << n << endl;
delete b;