|
发表于 2003-4-13 02:15:17
|
显示全部楼层
Re: 急
#include <stdio.h>
main()
{
float a[11];
~~~how many u want? if 10 float, then define a[10]
int i;
for(i=1;i<10;i++)
~~~~~array in c begins from 0, a[0], a[1]...a[9]. so u should use i=0; i<10;i++
{
scanf("%f \n",&a);
~~~this \n is not wrong. but useless.
}
printf("\n");
for(i=1;i<11;i++)
~~~here u should use i<10 again.
{
printf("%f \n",a);
}
}
so u basic problem is 'the index of array in c'.
if u define a[x]. then it is from 0, 1, 2,,, x-1. u access to a[x] will have problem. |
|