第五题这样做不知道是不是很笨😣 #include<iostream> (5488)#include<string> #include<ctime> (16669)#include<vector> using namespace std; int main() { int l; cin >> l; srand(time(NULL)); int ba = (rand() % (10000 - 1000) + 1000); string b=to_string(ba); string c; for (int m = 0; m < l; m++) { cin >> c; int bb = 0; int dd = 0; vector<int> v; for (int a = 0; a < b.length(); a++) { if (b[a] == c[a]) { bb = bb + 1; } else if (b[a] != c[a]) { v.push_back(a); } } for (vector<int>::iterator it = v.begin(); it != v.end(); it++) { for (vector<int>::iterator its = v.begin(); its != v.end(); its++) { if (b[*it] == c[*(its)] &;&; it != its) { dd = dd + 1; } } } cout << "你对了" << bb << "个数字" << endl; cout << "其中你有" << dd << "在里面但是位置不对" << endl; } cout << "最终数字为" << b << endl; }

相关推荐

01-29 15:45
已编辑
华中科技大学 前端工程师
COLORSN:可以试一下,小厂看技术栈是不是很落后,如果太拉胯就别去,个人认为有实习氛围比你自己琢磨要高效不少,然后就是小厂其实也有可能会问的很难,这都比较难说,还是看自己项目含金量够不够,寒假还能不能推进学习再选择,毕竟去实习过年就10天假了
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务