糕手不行了 大家救救我代码没问题运行不了
#include
int main()
{
int n,m,i,p,j,k,t,v,e,sho,ls,lp,q;
int sum1=0;
int sum2=0;
int sum3=0;
int a[n];
int b[m];
scanf("%d %d",&n,&m);
for(i=0;i {
scanf("%d",&a[i]);
getchar();
sum1=sum1+a[i];
}
for(p=0;p {
scanf("%d",&b[p]);
getchar();
sum2=sum2+b[p];
}
sho=sum1+sum2;
for(t=0;t {
sum3=0;
for(v=t;v {
sum3=sum3+b[v];
if(sum3>sum1)
e=sum3-sum1;
else e=sum1-sum3;
if (sho>e)
{
sho=e;
ls=t;
lp=v;
}
}
}
for(i=ls;i<=lp;i++)
{
printf("%d ",b[i]);
}
return 0;
}
#c语言学习##c语言编程#
int main()
{
int n,m,i,p,j,k,t,v,e,sho,ls,lp,q;
int sum1=0;
int sum2=0;
int sum3=0;
int a[n];
int b[m];
scanf("%d %d",&n,&m);
for(i=0;i
scanf("%d",&a[i]);
getchar();
sum1=sum1+a[i];
}
for(p=0;p
scanf("%d",&b[p]);
getchar();
sum2=sum2+b[p];
}
sho=sum1+sum2;
for(t=0;t
sum3=0;
for(v=t;v
sum3=sum3+b[v];
if(sum3>sum1)
e=sum3-sum1;
else e=sum1-sum3;
if (sho>e)
{
sho=e;
ls=t;
lp=v;
}
}
}
for(i=ls;i<=lp;i++)
{
printf("%d ",b[i]);
}
return 0;
}
#c语言学习##c语言编程#
全部评论
救救我!救救我!c语言的热爱
移动端看到的,排版和代码可读性有待提升()
相关推荐