|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
int b;int c;
printf("Please note how many figures are there in the nums:");
scanf("%d",&c);
int a[c];
int y;
for(y=0;y<c;y++)
{
printf("请输入第%d位数字:",y+1);
scanf("%d",&a[y]);
}
printf("Please input the target=");
scanf("%d",&b);
int i,j;
for (i=0;i<c-1;i++)
{
for(j=1;j<c;j++)
{
if(a[i]+a[j]==b)
{
printf("[%d,%d]",i,j);
}
}
}
return 0;
报错是runtime error: variable length array bound evaluates to non-positive value 0 [solution.c]
如果不能使用变量初始化数组那能用这种思路解这道题吗?
输入数组中的元素然后赋值给数组能实现吗?
leetcode 应该是不要求和标准输入/输出进行交互的,输入作为参数传入,输出作为返回值传出,因此您的数据获取方式可能有问题。
您也许可以参考 leetcode 的使用说明或帮助来确认如何使用此平台。
|
|