求助,数据1数据2在编译器上全对,到洛谷这一个RE一个WA
  • 板块P1928 外星密码
  • 楼主xxmdd
  • 当前回复3
  • 已保存回复3
  • 发布时间2022/2/19 00:18
  • 上次更新2023/10/28 08:13:48
查看原帖
求助,数据1数据2在编译器上全对,到洛谷这一个RE一个WA
370691
xxmdd楼主2022/2/19 00:18
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
int i=0;   
char a[30000];    
char* digui();

char* digui ()
{
    i++;
    int n;
    int j=0;
    char str[30000]; 
    while (i < strlen(a))
    {
        if (a[i] >= '0' && a[i] <= '9')
        {
            if (a[i+1] >= '0' && a[i+1] <= '9')
            {
                n = (a[i] - '0') * 10 + (a[i+1] - '0');
                i++;
            }
            else
            {
                n = (a[i] - '0');
            }
        }
        else if (a[i] == '[')
        {
        	char temp[30000];    	
        	strcpy(temp,digui());
        	int num=strlen(str);
  			for (int z=0;z<strlen(temp);z++)
  			{
  				str[z+num] = temp[z];
			}
		}
		else if (a[i] == ']')
		{
			int temp = strlen(str);
			int temp2 = 0;
			int length = strlen(str);
			for (int z=length;z<n*length;z++)
			{
				str[temp] = str[temp2];
				temp++;
				temp2++;
				
			}
		//	printf("%s",str); 
			return str;
		}
		else
		{
			str[j] = a[i];
			j++; 
		}
		i++;
	}

    return str;
}

int main (void)
{
    scanf ("%s",a);

    while (i < strlen(a))
    {
        if (a[i] == '[')
        {
			
 			printf ("%s",digui());
        }
        else
        {
            printf ("%c",a[i]);
        }
        i++;
    }
    return 0;
}
2022/2/19 00:18
加载中...