📄 2887964_ac_249ms_476k.c
字号:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int mark[1000];
struct node
{
int l;
char str[5][81];
}ref[1000];
int no;
int check(char tmp[])
{
int i;
for(i = 0; tmp[i]!='\0'; i++)
if(tmp[i]!=' ')
return 0;
return 1;
}
int out[1000];
int main()
{
int i, j, no, num, mm, mmm;
char tmp[81];
no = 1;
memset(mark,0,sizeof(mark));
while(gets(tmp))
{
if(check(tmp))
continue;
if(tmp[0]!='[')
{
mm = 0;
while(1)
{
for(i = 0; tmp[i]!='\0'; i++)
{
if(tmp[i]=='[')
{
putchar('[');
num = atoi(&tmp[i+1]);
if(mark[num]==0)
{
out[no] = num;
mark[num] = no++;
}
printf("%d",mark[num]);
i++;
while(tmp[i]!=']')
i++;
i--;
}
else
printf("%c",tmp[i]);
}
printf("\n");
if(gets(tmp))
{
if(check(tmp))
{
puts("");
mm = 1;
break;
}
}
else
break;
}
}
else
{
mmm = 0;
num = atoi(&tmp[1]);
strcpy(ref[num].str[0],tmp);
ref[num].l = 1;
while(gets(tmp))
{
if(check(tmp))
{
strcpy(ref[num].str[ref[num].l++],"");
mmm = 1;
break;
}
else
strcpy(ref[num].str[ref[num].l++],tmp);
}
if(mmm==0)
{
strcpy(ref[num].str[ref[num].l++],"");
}
}
}
if(mm==0)
puts("");
for(i = 1; i < no; i++)
{
printf("[%d]",i);
puts(&ref[out[i]].str[0][strlen(itoa(out[i],tmp,10))+2]);
for(j = 1; j < ref[out[i]].l; j++)
puts(ref[out[i]].str[j]);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -