C语言题目,代码错哪,怎么改
答案:1 悬赏:60 手机版
解决时间 2021-11-18 21:41
- 提问者网友:欺烟
- 2021-11-18 16:09
C语言题目,代码错哪,怎么改
最佳答案
- 五星知识达人网友:胯下狙击手
- 2021-11-18 17:15
int main()
{
int n, ch[100], i, min, t, j;
while ( ~scanf( "%d", &n ) )//
{
if(n==0)break;
for ( i = 0; i < n; i++ )
scanf( "%d", &ch[i] );
min = ch[0];
for ( i = 0; i < n; i++ )
{
if ( min > ch[i] )
{
min = ch[i];
j = i;
}
}
t = ch[0];
ch[0] = min;
ch[j] = t;
for ( i = 0; i < n; i++ )
printf( "%d ", ch[i] );//你的代码中有取地址符,应去掉
printf("
");
}
return 0;
}以上是我写的代码
while (~scanf("%d", &n),n!=0)
{
int n, ch[100], i, min, t, j;
while ( ~scanf( "%d", &n ) )//
{
if(n==0)break;
for ( i = 0; i < n; i++ )
scanf( "%d", &ch[i] );
min = ch[0];
for ( i = 0; i < n; i++ )
{
if ( min > ch[i] )
{
min = ch[i];
j = i;
}
}
t = ch[0];
ch[0] = min;
ch[j] = t;
for ( i = 0; i < n; i++ )
printf( "%d ", ch[i] );//你的代码中有取地址符,应去掉
printf("
");
}
return 0;
}以上是我写的代码
while (~scanf("%d", &n),n!=0)
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯