开放大学在线学习搜题
当前位置:首页 > 学习题库 > C程序设计语言

问题

若有以下输入,则下面程序的运行结果是( )。 1 4 2 3 3 4 1 2 3 3 2 2 2 3 3 1 1 1 4 1 1 1 -1 #define M 50

发布时间:2025-10-19   作者:ybf079400   浏览:0

若有以下输入,则下面程序的运行结果是(    )。

1 4 2 3 3 4 1 2 3 3 2 2 2 3 3 1 1 1 4 1 1 1 -1

 

#define M 50

main()

{

int a[M],c[4],i,n=0,x;

printf("Enter 1 or 2 or 3 or 4,to end with -1\n");

scanf("%d",&x);

while(x!=-1)

{

if(x>0&&x<=4)

{

a[n-1]=x;

n++;

}

scanf("%d",&x);

}

for(i=0; i<4; i++) c[i]=0;

for(i=0; i

printf("The result is:\n");

for(i=1; i<=4; i++) printf("%d:%d\n",i,c[i-1]);

printf("\n");

}

您可能感兴趣的试题