zoukankan      html  css  js  c++  java
  • XidianOJ 1142 删除字符

    --正文

    思路是遍历B,记录出现的字符(反正字符总共就那么几个)

    刚开始超时了,因为去用strcat来拼接字符串。但事实上直接输出就好

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <algorithm>
    using namespace std;
    
    char str[100000];
    char str2[100000];
    int appear[100000] = {0};
    int main(){
        int n;
        while (scanf("%s %s",str,str2) != EOF){
            int len = strlen(str2);
            int i;
            memset(appear,0,sizeof(appear));
            for (i=0;i<len;i++){
                appear[str2[i]] = 1;
            }
            char * now = str;
            bool empty = true;while ( *now != ''){
                if (appear[*now]) {
                }
                else {
                    empty = false;
                    printf("%c",*now);    
                }
                now ++;
            }    
            if (empty) {
                printf("EMPTY
    ");
                continue;
            }
            printf("
    ");
        }
    
        return 0;
    }
  • 相关阅读:
    python函数及模块
    Python分支结构及循环结构
    python基本的知识
    11.21学习总结
    进度日报28
    进度日报27
    进度日报26
    进度日报25
    进度日报24
    11.14学习总结
  • 原文地址:https://www.cnblogs.com/ToTOrz/p/6084938.html
Copyright © 2011-2022 走看看