#include<stdio.h>
void main()
{
int space=0,c;
printf("please input some number");
while((c=getchar())!='\n')
if (c==' ')
space++;
int a[space+1],i;
for(i=0;i<space+1;i++)
scanf("%d",&a[i]);
}
目的:输入一串数字,用空格隔开,然后赋值给数组,能怎么改下?
你的程序和你的题目相差悬殊呀,我想你的本意应该是:
输入:123 456 789 ,然后分割赋值
a[0] = 123;
a[1] = 456;
a[2] = 789;
是这个意思吧