码迷,mamicode.com
首页 > 编程语言 > 详细

算法初步——哈希表B1029/A1084. 旧键盘

时间:2020-01-05 20:53:58      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:false   mat   color   http   ima   print   max   com   har   

技术图片

 

 

#include <bits/stdc++.h>
#include<math.h>
#include <string>
using namespace std;
const int MAX_LEN = 2005;
void upper(char *s, int length) {
    int i = 0;
    for (i = 0; i < length; i++) {
        if (s[i] >= a && s[i] <= z) {
            s[i] -= a - A;
        }
    }
}
int ToUpper(int c)  
{  
    return toupper(c);  
}  
int main(){
    char str1[100],str2[100];
    bool HashTable[128] = {false};
    cin>>str1;
    cin>>str2;
    int len1 = strlen(str1);
    int len2 = strlen(str2);
    for(int i =0;i<len1;++i){
        int j;
        char c1,c2;
        for(j=0;j<len2;++j){
            c1 = str1[i];
            c2 = str2[j];
            if(c1 >= a && c1 <= z) c1 -= 32; //如果是小写字母,则转化为大写
            if(c2 >= a && c2 <= z) c2 -= 32;
            if(c1 == c2) break; 
        }
        if(j == len2 && HashTable[c1] == false){
            printf("%c",c1);
            HashTable[c1] = true;
        }
    }
    system("pause");
    return 0;
} 

算法初步——哈希表B1029/A1084. 旧键盘

标签:false   mat   color   http   ima   print   max   com   har   

原文地址:https://www.cnblogs.com/JasonPeng1/p/12153453.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!