第一行为一个整数n(n
接下来的2*n行,每2行一组,分别表示一部电影的名字和票房,其中名字部分长度
#include
int main()
{
int n;
scanf("%d",&n);
int i,j,ti[n],t=0;
char s[n][50];
for(i=0;i<n;i++)
{
printf("Enter the amount of the ticket:");
scanf("%d",&ti[i]);
printf("Enter the name of the film:");
for(j=0;s[i][j]!='\0';j++)
{
scanf("%c",&s[i][j]);
}
}
for(i=0;i<n;i++)
{
if(t<ti[i]) t=i;
}
for(i=0;i<50;i++)
{
printf("%c",s[t][i]);
}
}
新手请教C语言问题 找不出代码的错误 感谢
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
6条回答
- 计算机废物 2017-01-07 11:06关注
#include
#include
int main()
{int i,j,ti[100],t=0;//数组要一开始就分配好长度,不能那样子定义
char s[100][50];
for(i=0;i<100;i++)
{
printf("Enter the amount of the ticket:");
scanf("%d",&ti[i]);
printf("Enter the name of the film:");
for(j=0;s[i][j]!='\0';j++)
{
scanf("%c",&s[i][j]);
}
}
for(i=0;i<100;i++)
{
if(t<ti[i]) t=i;
}
for(i=0;i<50;i++)
{
printf("%c",s[t][i]);
}
}本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 c程序不知道为什么得不到结果
- ¥40 复杂的限制性的商函数处理
- ¥15 程序不包含适用于入口点的静态Main方法
- ¥15 素材场景中光线烘焙后灯光失效
- ¥15 请教一下各位,为什么我这个没有实现模拟点击
- ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
- ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
- ¥20 有关区间dp的问题求解
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置