华为第三题有ac的吗?

第三题33%不知道为什么,有大神ac了吗?
解下惑,谢谢!
#华为#
全部评论
题一样吗
点赞 回复 分享
发布于 2017-08-16 21:24
楼主我跟你一样
点赞 回复 分享
发布于 2017-08-16 21:29
输入要while(getline())
点赞 回复 分享
发布于 2017-08-16 21:31
scan.nex()过了33.4%  ,  改成scan.nextLine()过了66.7%
点赞 回复 分享
发布于 2017-08-16 21:31
88.83%
点赞 回复 分享
发布于 2017-08-16 21:32
import re mail = raw_input() #mail = "123@hu.123@we.i.com" pattern_split = re.compile(r"([\w\d\&\=\+\$\,\;\?\/\-\_\.\!\~\*\'\(\)\#]*@[\w\d-]+?\.)") pattern = re.compile(r"([\w\d\&\=\+\$\,\;\?\/\-\_\.\!\~\*\'\(\)\#]*)@([\w\d-]+?)\.") res = "" for item in pattern_split.split(mail):     match = pattern.match(item)     if match:         g1 = match.group(1)         g2 = match.group(2)         if len(g2) <= 119 and len(g1) >= 3:             res += (g1[:-3:] + "***" +"@"+g2+".")         else:             res += item     else:         res += item print res 直接把输入输出就过了50%了。。。 然后这样过了,别人的代码
点赞 回复 分享
发布于 2017-08-16 21:49
今天不是硬件、芯片、结构类的最后一场机试么?难道也有软件类的?
点赞 回复 分享
发布于 2017-08-16 21:51
楼下第2题多少
点赞 回复 分享
发布于 2017-08-16 21:56
#include <string> #include <cstring> #include <iostream> #include <cstdlib> #include <vector> #include <algorithm> #include <set> #include <queue> #include <stack> #include <map> using namespace std; #define pb push_back #define mp make_pair #define maxn 111 #define DEBUG bool fl[2222]; bool used[2222]; int main() { string s; while (getline(cin, s)) { memset(used, false, sizeof(used)); memset(fl, true, sizeof(fl)); int len = s.length(); bool pre = false; string ans = ""; for (int i = 0; i < len; ++i) { if (s[i] == '@') { int st = i + 1; // check 119 characters while (st < len && s[st] != '.' && s[st] !='@' && (isdigit(s[st]) || s[st] == '-' || isalpha(s[st]))) st++; if (st == len || st - i > 119 || s[st] != '.') continue; int last = st; // check if >=3 characters st = i - 1; while (i - st < 4 && st >= 0 && !used[st] && s[st] != '@' && (isdigit(s[st]) || isalpha(s[st]) || s[st] == '&' || s[st] == '=' || s[st] == '+' || s[st] == '$' || s[st] == ',' || s[st] == ';' || s[st] == '?' || s[st] == '/' || s[st] == '-' || s[st] == '_' || s[st] == '.' || s[st] == '!' || s[st] == '~' || s[st] == '*' || s[st] == '\'' || s[st] == '(' || s[st] == ')' || s[st] == '#')) st--; if (i - st == 4) { for (int j = st + 1; j < i; ++j) { fl[j] = false; } for (int j = i + 1; j <= last; ++j) used[j] = true; } } } for (int i = 0; i < len; ++i) { cout << (fl[i] ? s[i] : '*'); } cout << endl; } return 0; }
点赞 回复 分享
发布于 2017-08-16 22:02
#define _CRT_SECURE_NO_WARNINGS #include <vector> #include <iostream> #include<string> using namespace std; bool isE(char t){ if((t>='a'&&t<='z')||(t>='A'&&t<='Z')) return true; return false; } bool isN(char t){ if((t>='0')&&(t<='9')) return true; return false; } bool isS(char t){ if(t=='&')return true; if(t=='=')return true; if(t=='+')return true; if(t=='$')return true; if(t==',')return true; if(t==';')return true; if(t=='?')return true; if(t=='/')return true; if(t=='-')return true; if(t=='_')return true; if(t=='.')return true; if(t=='!')return true; if(t=='~')return true; if(t=='*')return true; if(t=='\'')return true; if(t=='(')return true; if(t==')')return true; if(t=='#')return true; return false; } bool isH(char t){ if(t=='-') return true; return false; } int scanAddress(string& str,int index){ int count=0; while(isE(str[index+count])|isN(str[index+count])|isS(str[index+count])){ count++; } return count; } int scanName(string& str,int index){ int count=0; while(isE(str[index+count])|isN(str[index+count])|isH(str[index+count])){ count++; } return count; } void fake(string& str,int index){ str[index-1]='*'; str[index-2]='*'; str[index-3]='*'; } void fakeCore(string& str,int index,int length){ if(index>length-1) return; int count1=scanAddress(str,index); if(str[index+count1]=='@'&&count1>=3){ int count2=scanName(str,index+count1+1); if(str[index+count1+count2+1]=='.'&&count2<=119) fake(str,index+count1); fakeCore(str,index+count1+count2+2,length); }else{ fakeCore(str,index+count1+1,length); } } int main() { #if 1 freopen("in.txt", "r", stdin); #endif //input string str; getline(cin,str); //fakeCore fakeCore(str,0,str.size()); //output cout<<str; }
点赞 回复 分享
发布于 2017-08-16 22:06
#include <bits/stdc++.h> using namespace std; /* int main(){     string mail;     set<char> sp;     string sps("&=+$,;?/-_.!~*'()#");     for(auto ch:sps) sp.insert(ch);     while(getline(cin, mail)){         vector<int> idx;         vector<int> node(1, -1);         for(int i=0; i<mail.size(); ++i){             if(mail[i] == '@') {                 idx.push_back(i);                 for(int j=i+1; j<mail.size(); ++j) {                     if(mail[j] == '.') {node.push_back(j); break;}                     if(mail[j] == '@') {node.push_back(i); break;}                 }             }         }         int flag = false;         int old = -1;         for(int i=0; i<idx.size(); ++i){             if(!flag){                 if(idx[i]-old >= 4 && node[i+1]-idx[i]-1 <= 119 && node[i+1]-idx[i] > 1){                     for(int k=idx[i]-1; k>=idx[i]-3; --k){                         if(!isalnum(mail[k]) && sp.find(mail[k]) == sp.end()){                             goto next;                         }                     }                     for(int k=idx[i]+1; k<node[i+1]; ++k){                         if(!isalnum(mail[k]) && mail[k] != '-'){                             goto next;                         }                     }                     for(int k=idx[i]-1; k>=idx[i]-3; --k){                         mail[k] = '*';                     }                     flag = true;                 }             }             else{                 if(idx[i]-node[i] >= 4 && node[i+1]-idx[i]-1 <= 119 && node[i+1]-idx[i] > 1){                     for(int k=idx[i]-1; k>=idx[i]-3; --k){                         if(!isalnum(mail[k]) && sp.find(mail[k]) == sp.end()){                             flag = false;                             goto next;                         }                     }                     for(int k=idx[i]+1; k<node[i+1]; ++k){                         if(!isalnum(mail[k]) && mail[k] != '-'){                             flag = false;                             goto next;                         }                     }                     for(int k=idx[i]-1; k>=idx[i]-3; --k){                         mail[k] = '*';                     }                 }                 else{                     flag = false;                 }             }         next:             old = idx[i];         }         cout << mail << endl;     } }*/
点赞 回复 分享
发布于 2017-08-16 23:19
能公布一下题目吗?
点赞 回复 分享
发布于 2017-08-17 09:31

相关推荐

头像
02-15 16:23
中南大学 Java
野猪不是猪🐗:签了美团真是不一样! 亲戚们都知道我签了美团,过年都围着我问送一单多少钱,还让弟弟妹妹们引以为戒,笑我爸我妈养了个🐢孩子,说从小就知道我这个人以后肯定没出息,我被骂的都快上天了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务