解题思路:
注意事项:下面的代码可以在我的VC上跑,不知道为啥平台上面跑不了,有无兄弟看一下啥原因
参考代码:
#include<stdio.h>
#include<malloc.h>
int main()
{
int n,i,j,cloth_nums,cloth_location,num = 0;
int *a1,*a2;
scanf("%d",&n);
a1 = (int*)malloc(sizeof(int)*(n+1));
for(i = 0;i<n+1;i++)
{
a1[i] = 0;
}
while(scanf("%d",&cloth_nums)!=EOF)
{
a2 = (int*)malloc(sizeof(int)*cloth_nums);
for(i = 0;i<cloth_nums;i++)
{
scanf("%d",&a2[i]);
}
scanf("%d",&cloth_location);
num = 0;
for(i = 0;i<cloth_nums;i++)
{
for(j=1;j<=a2[i];j++)
{
a1[num] = 1;
num++;
}
a1[num] = 2;
num++;
}
printf("%d\n",a1[cloth_location-1]);
for(i = 0;i<n+1;i++)
{
a1[i] = 0;
}
free(a2);
}
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:689 |
C语言程序设计教程(第三版)课后习题8.9 (C语言代码)浏览:650 |
妹子杀手的故事 (C语言代码)浏览:679 |
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C语言代码)浏览:1031 |
【绝对值排序】 (C++代码)浏览:670 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:703 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:559 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:1295 |
WU-格式化数据输出 (C语言代码)浏览:1745 |
文科生的悲哀 (C语言代码)浏览:1399 |