c语言 一维数组 长度自定的 输入数组数组的长度 并且输入n个数。

如何编程 ?

第1个回答  2006-12-23
#include "stdio.h"
main()
{
int i,n;
float a[100];
printf("please input the length of array A:\n");
scanf("%d",&n);
printf("please input the %d numbers:\n",n);
for(i=0;i<n;i++)
{
scanf("%f",&a[i]);
}
printf("the numbers are:\n");
for(i=0;i<n;i++)
{
printf("%g\n",a[i]);
}
getch();
}本回答被提问者采纳