zoukankan      html  css  js  c++  java
  • CCF_ 201509-3_模板生成系统

    又是一道考验细心和耐心的题,不知道哪里出问题了,一直只有90分 = =!

    #include<cstdio>
    #include<iostream>
    #include<cstring>
    using namespace std;
    
    char a[100][85];
    char name[205][105];
    
    int main()
    {
        int m,n;
        char *p;
        scanf("%d%d",&m,&n);
        getchar();
        for(int i = 0;i < m;i++)    gets(a[i]);
        for(int i = 0;i < 2*n;i += 2)
        {
            scanf("%s",name[i]);
            getchar();
            getchar();
            gets(name[i+1]);
            p = name[i+1];
            while(*p != '"')  p++;
            *p = 0;
        }
        for(int i = 0;i < m;i++)
        {
            p = a[i];
            while(*p != 0)
            {
                if(*p == '{' && *(p+1) == '{')
                {
                    p += 3;
                    char *temp = p;
                    int num = 0;
                    while(!(*p == ' ' && *(p+1) == '}' && *(p+2) == '}'))
                    {
                        num++;
                        p++;
                    }
                    p += 3;
                    for(int j = 0;j < 2*n;j++)
                    {
                        if(num == strlen(name[j]) && !strncmp(name[j],temp,num))    printf("%s",name[j+1]);
                    }
                }
                else
                {
                    putchar(*p);
                    p++;
                }
            }
            putchar('
    ');
        }
        return 0;
    }
  • 相关阅读:
    安卓中期小作业
    安卓大作业UI预定搞
    实验3
    实验一总结
    实验8 SQLite数据库操作
    实验6 在应用程序中播放音频和视频
    实验4 颜色、字符串资源的使用
    实验四
    实验三
    实验二
  • 原文地址:https://www.cnblogs.com/zhurb/p/5847329.html
Copyright © 2011-2022 走看看