可以請問一下為何此c語言程式不能執行嗎?
這是程式
Write a program that prompts the user to input a number “n” (1 ≤ n ≤30), and then prompts the user to input n numbers between 0 and 100.
And then prints them first forward and then reversed ( the last one first ), as shown in the following design.
Please input n (1-30): 5
Please input 5 numbers (0-100): 10 20 3 17 99
Your numbers forward : 10 20 3 17 99
Your numbers reversed: 99 17 3 20 10
這是程式碼
#include <stdio.h>
int main(void)
{
int array[10000000],a,j;
printf("Please input n (1-30):");
scanf("%d",&a);
printf("\nPlease input %d numbers (1-100):",a);
for(j=0;j<a;j++)
{
scanf("%d",&array[j]) ;
}
printf("\nYour numbers forward:");
for(j=0;j<a;j++)
{
printf("%d",array[j]);
}
printf("\nYour numbers reverse:");
for(j=a-1;j>=0;j--)
{
printf("%d",array[j]);
}
return o;
}
1 個解答
- ?Lv 41 0 年前最佳解答
#include <stdio.h>
#include <stdlib.h> //為了呼叫 system("pause")
int main(void)
{
//int array[10000000],a,j; 宣告陣列太大 , 每一個編譯器都有限制
int array[100000], a, j;
printf("Please input n (1-30):");
scanf("%d",&a);
printf("\nPlease input %d numbers (1-100):",a);
for(j=0;j<a;j++)
{
scanf("%d",&array[j]) ;
}
printf("\nYour numbers forward:");
for(j=0;j<a;j++)
{
//printf("%d",array[j]);
printf("%d ",array[j]); //%d後面加空格把數字隔開
}
printf("\nYour numbers reverse:");
for(j=a-1;j>=0;j--)
{
//printf("%d",array[j]);
printf("%d ",array[j]);//%d後面加空格把數字隔開
}
system("pause"); //最好加這個,可看結果
//return o; 你打英文字母O, 非數字 0
return 0;
}