这个c代码输出超限,求大神帮我kan'xia 5
#include<stdio.h>intmain(){intn,m,c;inta[100];inti,j,k=1;intt,temp;intsum,num,max;whi...
#include<stdio.h>
int main()
{
int n,m,c;
int a[100];
int i,j,k=1;
int t,temp;
int sum,num,max;
while(1)
{
sum=0;
max=0;
t=sum;
scanf("%d%d%d",&n,&m,&c);
if(n==0&&m==0&&c==0)
break;
else
printf("Sequence %d\n",k);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(j=1;j<=m;j++)
{
scanf("%d",&num);
sum+=a[num-1];
a[num-1]=0-a[num-1];
if(sum>c)
{
printf("Fuse was blown.\n");
break;
}
if(sum>t)
t=sum;
}
if(sum<=c)
{ printf("Fuse was not blown.\n");
printf("Maximal power consumption was %d amperes.\n",t);
}
putchar('\n');
k++;
}
return 0;
} 展开
int main()
{
int n,m,c;
int a[100];
int i,j,k=1;
int t,temp;
int sum,num,max;
while(1)
{
sum=0;
max=0;
t=sum;
scanf("%d%d%d",&n,&m,&c);
if(n==0&&m==0&&c==0)
break;
else
printf("Sequence %d\n",k);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(j=1;j<=m;j++)
{
scanf("%d",&num);
sum+=a[num-1];
a[num-1]=0-a[num-1];
if(sum>c)
{
printf("Fuse was blown.\n");
break;
}
if(sum>t)
t=sum;
}
if(sum<=c)
{ printf("Fuse was not blown.\n");
printf("Maximal power consumption was %d amperes.\n",t);
}
putchar('\n');
k++;
}
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询