Inputting a set of variable length data is stored to the array, and output.
Available Code:
#include<stdio.h>
int main() //输入一组不定长数据存到数组中,并输出。
{
int a[101],n=0;
while(1)
{
scanf("%d",&a[n++]);
if(getchar()=='\n')
break;
}
for(int i=0;i<n;i++)
printf("%d ",a[i]);
return 0;
}
Unavailable codes (both of two input data are stored to two arrays, the modifications from the above code):
#include<stdio.h>
int main() //输入数据俩俩分别存到两的数组中,并输出。
{
int a[101],n=0,b[101];
while(1)
{
scanf("%d %d",&a[n++],&b[n++]);
if(getchar()=='\n')
break;
}
for(int i=0;i<n;i++)
printf(" %d %d \n",a[i],b[i]);
return 0;
}
The second paragraph of code runs (gcc) Results: