要求输入整数数组,这样就可以完整实现。。
int main()
{
int nRes = 0,nData = 0,i = 0,nArr[100] = {0};
while (1)
{
nRes = scanf("%d",&nData);
if (nRes == 1)
{
nArr[i ++] = nData;
if (i >= 100)
{
break;
}
}
else if (nRes == 0)
{
scanf("%*c");
}
else if (nRes == EOF)
{
break;
}
}
return 0;
}
关于 * 的解释:
An asterisk (*) following the percent sign suppresses assignment of the next input field, which is interpreted as a field of the specified type. The field is scanned but not stored.