华为第三道题目

第三题怎么改都只有37.5,有大佬100AC的吗,要求的输出顺序到底是什么呀?大雾
全部评论
75% +1. 检查半天看不出漏了哪种情况,题名还特意说明 没有非法输入。 最逗的是题目要求按升序,而例子是降序。
点赞 回复 分享
发布于 2017-09-20 21:22
#include <iostream> #include <cstring> #include <string> #include <cstdlib> #include <cstdio> #include <vector> #include <stack> #include <algorithm> #include <set> #include <queue>  #include <cctype> #include <cmath> #include <map> #include <unordered_map> #include <deque> #include <sstream> using namespace std; void replace(string str, const string &bitset, unordered_map<int, int> &record, char nc){     bool flag = false;     int idx = 1;     int i = bitset.size() - 1;     while(i >= 0) {         if(bitset[i] == '1') {             int strIdx = record[idx];             str[strIdx] = nc;             flag = true;         }         --i;         ++idx;     }     if(flag) {         cout << ',' << str;     } } bool nextBitSet(string &bitset) {     const int len = bitset.size();     if(bitset[len-1] == '0') {         bitset[len-1] = '1';         return true;     }     int curIdx = len-1;         while(curIdx >= 0) {         if(bitset[curIdx] == '0') {             bitset[curIdx] = '1';             break;         }         bitset[curIdx--] = '0';     }     if(curIdx < 0) return false;     return true; } int main() {          string str;     char oc, nc;     cin >> str >> oc >> nc;     oc = tolower(oc);     unordered_map<int, int> record;     const int len = str.size();     int idx = 1;     int maxIdx = -1;     bool found = false;     for(int i = len-1; i >= 0; --i) {         char ch = tolower(str[i]);         if(ch == oc) {             found = true;             record[idx++] = i;             maxIdx = (idx > maxIdx? idx : maxIdx);         }     }     if(found) {                 string bitset(maxIdx-1, '0');                 cout << str;         while(nextBitSet(bitset)) {             replace(str, bitset, record, nc);         }         cout << endl;             }else{         cout << str << endl;     }     return 0; } 100%通过
点赞 回复 分享
发布于 2017-09-20 21:19
public class Main {     public static void main(String[] args) {         Scanner s = new Scanner(System.in);         String str = s.nextLine();         String[] strings = str.split(" ");                  TreeSet<String> ts = new TreeSet<String>(new Comparator<String>(){             @Override             public int compare(String o1, String o2) {                                  return o2.compareTo(o1);             }                      });         ts.add(strings[0]);                  new Test3().swap(ts,strings[0],strings[1],strings[2]);                           String last = ts.pollLast();         for (String string : ts) {             System.out.print(string+",");         }         System.out.println(last);                                    s.close();     }     public TreeSet<String> swap(TreeSet<String> ts,String str1,String str2,String str3){         for (int i = 0; i < str1.length(); i++) {             if(str2.equals(str1.charAt(i)+"")){                 StringBuilder sb = new StringBuilder(str1);                 String string = sb.replace(i, i+1, str3).toString();                 ts.add(string);                 swap(ts,string,str2,str3);             }         }         return ts;     } } 不知道对错啊,大神帮看一看
点赞 回复 分享
发布于 2017-09-20 21:18
// 华为第三题.cpp : 定义控制台应用程序的入口点。// include "stdafx.h" include <iostream> include <string> include <vector> using namespace std; int main(){ string input; string src; string dest; cin >> input>>src>>dest; string mytemp; int num = 0; for (int i = 0; i < input.size(); i++) { if (input[i] == src[0]) { num++; mytemp.push_back('0'); } } string stard; for (int i = 0; i < num; i++) { stard.push_back('1'); } vector<string> res; for (int i = 0; i < pow(2, num); i++) { string restemp = input; int cnt = 0; for (int j = 0; j < input.size(); j++) { if (restemp[j] == src[0]) { if (src[0] > dest[0]) { if (mytemp[cnt] == '1') { restemp[j] = dest[0]; } } else { if (mytemp[cnt] == '0') { restemp[j] = dest[0]; } } cnt++; } } res.push_back(restemp); int k = 1; int jinwei = 1; while (jinwei == 1 && mytemp!=stard) { if (mytemp[num - k] == '0') { mytemp[num - k] = '1'; k++; jinwei = 0; } else if (mytemp[num - k] == '1') { mytemp[num - k] = '0'; jinwei = 1; k++; } } } for (int i = 0; i < res.size()-1; i++) { cout << res[i] <<','; } cout << res[res.size() - 1] << endl; cin.get(); cin.get(); return 0; }
点赞 回复 分享
发布于 2017-09-20 21:13
75%的路过。
点赞 回复 分享
发布于 2017-09-20 21:11
没用一题100AC  也是服了
点赞 回复 分享
发布于 2017-09-20 21:11
百分之75路过。。
点赞 回复 分享
发布于 2017-09-20 21:09

相关推荐

Kurumis:整个简历看下来就发现你其实对测试理解还很浅,很多地方都是硬凑上去,项目也是学生课设级别,没什么含金量 首先是学习建议: 1.系统性了解一个真实工程的框架,有利于你后续提升项目含金量,理解测试的逻辑 2.真正去学一下自动化测试和性能测试 再就是简历本身包装问题: 1.投测试的话就不要说自己独立开发自己测,专注描述自己怎么做测试的 2.项目经历太像套话,很容易让人怀疑你到底真的做过没有,比如并发是具体做了多少并发?自动化脚本是怎么跑兼容性和性能测试的?测试用例写了多少条? 3.教务管理系统一听就是数据库课设作业,含金量不高,不过你可以在原项目基础上重构扩展,比如添加docker容器部署MySQL和Redis,添加消息队列和锁机制防止系统扛不住高并发访问,让它真的像个实际工程 4.技能里性能专项测试没有把握不要乱写,就写你会什么工具就行了,做专项性能测试的都是行业大佬,你要写的话一定要有对应的专项性能测试项目 5.可以在简历里附上项目链接,压缩简历内容的同时提升简历真实性
今天你投了哪些公司?
点赞 评论 收藏
分享
03-26 12:00
已编辑
门头沟学院 Java
offer魅魔_oc...:100-200每天,你还要倒贴100
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务