字符串
小岛上的盛夏
这个作者很懒,什么都没留下…
展开
-
PAT 乙级 1086 就不告诉你(15 分)---【数组反转】
思路: 1.利用数组反转函数,将int转化为string(to_string) 2.reverse(s.begin(),s.end())反转,s.end()是最后一位的下一位 3.再将string(stoi())转化为int型输出 注意: 最后输出是数字! 代码: #include<bits/stdc++.h> using namespace std; int main(){ int a,b; cin>>a>>b; int c=a*b; //int.原创 2020-11-26 20:31:03 · 147 阅读 · 0 评论 -
字符串去除空白输出
#include <iostream> #include <sstream> #include <string> using namespace std; int main() { string s = "Somewhere down the road"; istringstream iss(s); string c; do { string subs; iss >> subs; //原创 2020-11-26 20:14:51 · 110 阅读 · 0 评论 -
PAT 乙级 1095 解码PAT准考证 (25 分)
#include <iostream> #include <vector> #include <unordered_map> #include <algorithm> using namespace std; struct node { string t; int value; }; bool cmp(const node &a, const node &b) { return a.value != b.value ?原创 2020-11-26 19:33:20 · 83 阅读 · 0 评论 -
PAT 乙级 1094 谷歌的招聘 (20分)---【素数 字符串】
自然常数 e 是一个著名的超越数,前面若干位写出来是这样的:e = 2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003059921… 其中粗体标出的 10 位数就是答案。 本题要求你编程解决一个更通用的问题:从任一给定的长度为 L 的数字中,找出最早出现的 K 位连续数字所组成的素数。 输入格式: 输入在第一行给出 2 个正整.原创 2020-11-26 17:45:47 · 649 阅读 · 0 评论 -
map的用法集中
参考:https://www.cnblogs.com/fnlingnzb-learner/p/5833051.html原创 2020-11-20 14:42:11 · 67 阅读 · 0 评论 -
PAT 乙级 1002 写出这个数 (20分)---【字符串,数组】
思路: 1.因为输入int数字是<=100位,用string字符串输入 2.再循环把每个数字(字符串类型)转换成int类型(-48/‘0’);与此同时做总和运算sum 3.写一个字符串数组,存放拼音char str[10][10]/string str[10] 4.把sum(int)转换成string(to_string(sum)),遍历sum中每位,输出对应下标上的拼音。 代码: #include<bits/stdc++.h> using namespace std; in.原创 2020-11-19 21:13:25 · 98 阅读 · 0 评论