acm 有序数列中插入数据 http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=10474
总是RE#include<stdio.h>intmain(){intcount,n,i,j,insert;inta[1000];scanf("%d",&count);wh...
总是RE
#include<stdio.h>
int main()
{
int count,n,i,j,insert;
int a[1000];
scanf("%d",&count);
while(count--)
{
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
scanf("%d",&insert);
for (i=0; i<n; ++i)
{
if (insert < a[i])
{
for (j=n; j>i; --j)
a[j] = a[j-1];
a[i] = insert;
n++;
break;
}
}
printf("%d", a[0]);
for (i=1; i<n; ++i){
printf(" %d", a[i]);
}
printf("\n");
}
return 0;
}
vc能够运行通过,但是提交老是RE 展开
#include<stdio.h>
int main()
{
int count,n,i,j,insert;
int a[1000];
scanf("%d",&count);
while(count--)
{
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
scanf("%d",&insert);
for (i=0; i<n; ++i)
{
if (insert < a[i])
{
for (j=n; j>i; --j)
a[j] = a[j-1];
a[i] = insert;
n++;
break;
}
}
printf("%d", a[0]);
for (i=1; i<n; ++i){
printf(" %d", a[i]);
}
printf("\n");
}
return 0;
}
vc能够运行通过,但是提交老是RE 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询