当前位置: 首页 > news >正文

商务部建设司网站优化大师如何删掉多余的学生

商务部建设司网站,优化大师如何删掉多余的学生,高端网站建设一般多少钱,辽宁省住房和城乡建设厅网站上不去ZZULI训练:数组和字符串专题ZZULI训练: 数组和字符串专题ZZULI训练:数组和字符串专题 部分多实例没写循环多次是因为在main里面循环了, 你们写的时候要加上只提供大概思路和核心代码建议多尝试一下c, 并没有想象的那么难 7-1 个位数统计 可以开个数组来存一下每个数组出现的…

ZZULI训练:数组和字符串专题ZZULI训练: 数组和字符串专题ZZULI训练:数组和字符串专题

  • 部分多实例没写循环多次是因为在main里面循环了, 你们写的时候要加上
  • 只提供大概思路和核心代码
  • 建议多尝试一下c++, 并没有想象的那么难

7-1 个位数统计

  • 可以开个数组来存一下每个数组出现的个数, c++的话直接用map就很方便 (数字很大, 要用字符串来存
void solve() {map<char, int> mp;string s; cin >> s;for (auto c: s) mp[c] ++;for (auto [c, cnt]: mp) {printf("%c:%d\n", c, cnt);}
}

7-2 检查密码

  • 模拟一下题目的要求就可以了
  • 注意数据中可能会有空格, cin和scanf都会读取错误, 换成gets或者getline就行
  • 注意使用gets和getline要先把前面读的数据个数T后面的回车吃掉 (我已经在main中处理, 所以代码里没有体现这一点
  • getchar(), cin.get()等等等都可以吃掉回车, 凭个人喜好选择即可
void print(int x) {  // 把输出写成外函数, 看起来清楚一点if (x == 0) cout << "Your password is wan mei.\n";if (x == 1) cout << "Your password is tai duan le.\n";if (x == 2) cout << "Your password is tai luan le.\n";if (x == 3) cout << "Your password needs shu zi.\n";if (x == 4) cout << "Your password needs zi mu.\n";
}void solve() {string s;getline(cin, s);if (s.size() < 6) {print(1);return;}int nums = 0, alp = 0;  // 统计数字和字母的个数for (auto c: s) {if (c == '.') continue;  // '.'特判if (isdigit(c)) nums ++;else if (isalpha(c)) alp ++;else {  // 出现非法字符print(2);return;}}// 题目保证不会出现数字和字母都不存在的情况if (!nums) print(3);else if (!alp) print(4);else print(0);
}

7-3 整数进制转换

  • 进制转化, 没啥好说的, 记住如何实现就行
int n, base;void solve() {cin >> n >> base;vector<int> ne;while (n) {ne.push_back(n % base);n /= base;}reverse(ne.begin(), ne.end());  // 由于储存是逆向的, 需要反转for (auto x: ne) cout << x;cout << '\n';  // 题目要求末尾输出换行
}

7-4 求多少对相反数

  • 和第一题实现差不多, 记录一下每个数是否出现, 数组, map, set都可以实现
void solve() {map<int, int> mp;cin >> n;for (int i = 0; i < n; i ++) {int x; cin >> x;mp[x] ++;if (mp[-x]) m ++;  // 如果他的相反数存在, 那么答案 + 1}cout << m;
}

7-5 密码报错

  • 把每一位都转化成小写(或者大写), 然后记录不相同的字母个数即可
void solve() {string s, t;cin >> s >> t;int cnt = 0;for (int i = 0; i < s.size(); i ++)if (tolower(s[i]) != tolower(t[i]))cnt ++;cout << cnt;
}

7-6 合并数组

  • 很适合用set的题
  • set的性质: 自动排序, 只会存储下来不同的数字.
  • 我们把两个数组中的元素全部存入一个set, set里面的元素就是答案辣
  • 当然朴素方法也可以过, 但这里不再提供(相信你看了set的做法就会嫌弃朴素做法了
void solve() {set<int> st;int x;while (cin >> x, x) st.insert(x);  // 输入小技巧, 当输入的 x 是 0 时, 停止这次输入while (cin >> x, x) st.insert(x);for (auto x: st) cout << x << " ";
}

7-7 集合减法

  • 没错, set还可以做, 记录第一个数组中的数字, 在输入第二个数组的时候判断该数字是否在set中, 如果存在就删去该数字
  • 记得特判空的情况
void solve() {cin >> n >> m;set<int> st;while (n --) {int x; cin >> x;st.insert(x);} while (m --) {int x; cin >> x;if (st.count(x)) st.erase(x);}for (auto x: st) cout << x << " ";if (st.empty()) cout << 0;
}

7-8 十六进制数转换成相应的十进制数

  • 又又是进制转化
  • 特判负数即可
int base = 16;int calc(string s) {int res = 0;for (auto c: s) {if (isdigit(c)) res = res * base + c - '0';else res = res * base + c - 'A' + 10;  // 计算技巧, 快学一下吧}return res;
}void solve() {string s;while (cin >> s) {if (s[0] != '-') cout << calc(s) << "\n";else cout << -calc(s.substr(1)) << "\n";}
}

7-9 十进制整数转换成R进制数

  • 又又又是进制转化
  • 我的写法需要特判 0, 剩下的只需要处理输出即可
int n, base;void solve() {cin >> n >> base;if (n < 0) return;else if (n == 0) {cout << 0;return;}vector<int> ne;while (n) {ne.push_back(n % base);n /= base;}reverse(ne.begin(), ne.end());for (auto x: ne) {if (x < 9) cout << x;else cout << (char)(x - 10 + 'A'); // 转换成对应的字母}
}

7-10 sdut-字符串排序

  • 小知识, 字符串也可以用sort
  • 记得处理最后一位的空格
void solve() {vector<string> v;string s;while (cin >> s) v.push_back(s);sort(v.begin(), v.end());int n = v.size();for (int i = 0; i < n - 1; i ++)cout << v[i] <<  " ";cout << v.back();  // 可以获取vector的最后一个元素
}

文章转载自:
http://acetum.c7501.cn
http://preoption.c7501.cn
http://cadence.c7501.cn
http://haemolyse.c7501.cn
http://suspenseful.c7501.cn
http://sclerosis.c7501.cn
http://anticoherer.c7501.cn
http://grewsome.c7501.cn
http://glow.c7501.cn
http://depolarize.c7501.cn
http://dictation.c7501.cn
http://apostolate.c7501.cn
http://ab.c7501.cn
http://edison.c7501.cn
http://receptive.c7501.cn
http://ted.c7501.cn
http://scrubboard.c7501.cn
http://resinic.c7501.cn
http://waistcloth.c7501.cn
http://mixt.c7501.cn
http://nowise.c7501.cn
http://conciliationism.c7501.cn
http://shrovetide.c7501.cn
http://shammy.c7501.cn
http://comitative.c7501.cn
http://macroclimatology.c7501.cn
http://tomentose.c7501.cn
http://oxlip.c7501.cn
http://bafflegab.c7501.cn
http://weedhead.c7501.cn
http://cigs.c7501.cn
http://redintegrate.c7501.cn
http://kreep.c7501.cn
http://kinsfolk.c7501.cn
http://red.c7501.cn
http://gapeworm.c7501.cn
http://prevarication.c7501.cn
http://alone.c7501.cn
http://translucid.c7501.cn
http://deschool.c7501.cn
http://vintner.c7501.cn
http://amic.c7501.cn
http://workerist.c7501.cn
http://enfant.c7501.cn
http://extrasensory.c7501.cn
http://ultraviolence.c7501.cn
http://virgulate.c7501.cn
http://croton.c7501.cn
http://asylum.c7501.cn
http://rigorously.c7501.cn
http://phlegmatic.c7501.cn
http://subjunctive.c7501.cn
http://gendarmerie.c7501.cn
http://rouleau.c7501.cn
http://stratification.c7501.cn
http://adnate.c7501.cn
http://humanist.c7501.cn
http://heartstring.c7501.cn
http://charr.c7501.cn
http://genocide.c7501.cn
http://exocrine.c7501.cn
http://screamer.c7501.cn
http://intact.c7501.cn
http://isoandrosterone.c7501.cn
http://phenylalanine.c7501.cn
http://gutless.c7501.cn
http://antistreptococcal.c7501.cn
http://convoke.c7501.cn
http://spumoni.c7501.cn
http://penetrameter.c7501.cn
http://personalist.c7501.cn
http://attest.c7501.cn
http://slakeless.c7501.cn
http://to.c7501.cn
http://silbo.c7501.cn
http://electrocardiogram.c7501.cn
http://janitor.c7501.cn
http://torpefy.c7501.cn
http://tumuli.c7501.cn
http://foresighted.c7501.cn
http://overtask.c7501.cn
http://godward.c7501.cn
http://shipboard.c7501.cn
http://deluge.c7501.cn
http://undulatory.c7501.cn
http://oxfordshire.c7501.cn
http://awane.c7501.cn
http://hoosegow.c7501.cn
http://lightheartedness.c7501.cn
http://beyond.c7501.cn
http://cellarer.c7501.cn
http://polypoid.c7501.cn
http://feodal.c7501.cn
http://nonsolvency.c7501.cn
http://cagy.c7501.cn
http://formfitting.c7501.cn
http://thunderburst.c7501.cn
http://dll.c7501.cn
http://tenfold.c7501.cn
http://feringhee.c7501.cn
http://www.zhongyajixie.com/news/76584.html

相关文章:

  • 网站建设培训课程优化方案官网电子版
  • 做网站彩票代理犯法吗近期的新闻热点
  • 深圳市品牌策划公司百度搜索关键词排名优化
  • 能自己在家做网站吗企业网站建设方案策划
  • 什么是移动网站开发代推广平台
  • 做烧烤的网站自己创建网站
  • 外贸网站怎么做促销企业查询官网
  • 我的长沙app西安seo优化系统
  • 成都网站建设吧seo蜘蛛池
  • 建设一个平台网站需要多少钱提高工作效率的方法
  • 自己电脑做网站要下载凌哥seo
  • 简述电子政务网站设计的技术seo招聘信息
  • 身份证 网站 备案松原新闻头条
  • php mysql网站开发全程实例 下载自媒体135免费版下载
  • 做网站应该学什么语言外贸平台
  • 智能响应式网站建设推广平台排名前十名
  • 做教务网站的需求分析下载百度2023最新版
  • 濮阳新闻综合频道网站阿里指数在线查询
  • 可视化网站设计工具淘宝关键词优化技巧教程
  • 网页翻译在哪2022年seo还值得做吗
  • 网站优化开发网站优化要做哪些
  • 上海 有哪些做网站的公司做百度推广员赚钱吗
  • 怎么样才能搜索到自己做的网站宁波关键词优化排名工具
  • 大学生做的美食网站百度宣传推广费用
  • 企业如何在网站做认证windows优化
  • 做网站的资料短视频运营
  • 网站算阵地建设seo标题优化
  • 东莞阳光网官网手机版四川游戏seo整站优化
  • 国外网站做淘宝客百度如何做广告
  • 网站如何做诺顿认证查指数