首页
DreamJudge
院校信息
专业题库
模拟考试
机试真题
上岸课程
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
928上岸梦校!
2023年8月11日 09:59
字符串加法
P1012
回复 0
|
赞 1
|
浏览 957
#include <bits/stdc++.h> using namespace std; int main() { string s; string digits; string nd; cin >> s; for (auto i = s.begin(); i != s.end(); i++) { if (isdigit(*i)) { digits.push_back(*i); } else { nd.push_back(*i); } } cout <&l...
dongqing
2023年7月30日 17:07
字符移动 题解:
P1012
回复 0
|
赞 1
|
浏览 992
先输出非数字,将数字存入字符串,后再将数字字符串输出,注意字符串的范围,cnt,不然输出会有奇怪的符号。 #include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; char shuzi[100]; int cnt=0; for(int i=0;i<s.size();i++) { if(s[i]>='0'&&s[i]&...
要一根华子
2023年7月25日 12:18
字符移动 题解:
P1012
回复 0
|
赞 2
|
浏览 860
#include<bits/stdc++.h> #include <string> #include <algorithm> using namespace std; int main(){ char a[10]={'1','2','3','4','5','6','7','8','9','0'}; strin...
jix::c
2023年5月3日 22:31
字符移动 题解:
P1012
回复 0
|
赞 1
|
浏览 914
使用cpp的内置函数 isalnum():判断是否为数字或者字母 isalpha():判断是否为字母 判断是否为数字 if(isalnum(x) and !isalpha(x)) 使用这两个函数会省去很多时间 AC代码 #include <bits/stdc++.h> #define fi first #define endl '\n' #define se second #define pp pop_back #define pb push_back #define lowbit(x) ((x)&...
Hegel
2023年3月17日 15:56
输入字符串s,将其所有数字字符移动到非数字字符之后
P1012
回复 0
|
赞 1
|
浏览 2.7k
#include <iostream> #include <string> using namespace std; int main(){ string s,c= "",n = ""; cin>>s; for(int i =0;i<s.size();i++){ if(s[i]>='0'&&s[i]<='9') n = n+s[i]; else c = c+s[i]; } s = c + n; cout<<s; } 设置存储数字的字符串n...
LianG_nnuo
2022年11月11日 21:46
c
P1012
回复 0
|
赞 3
|
浏览 4.5k
#include<stdio.h> #include<stdlib.h> #include<string.h> /*输入一个字符串,将其中的数字字符移动到非数字字符之后,并保持数字字符和非数字字符输入时的顺序 例如:输入字符串“ab4f35gr#a6”,输出为“abfgr#a4356”。 复制 ab4f35gr#a6 输出样例#: 复制 abfgr#a4356*/ void main(){ int i,n,j=0,k=0; ...
cheng_kong
2022年8月2日 11:16
字符移动(双字符串合并—暴力)
P1012
回复 0
|
赞 4
|
浏览 5.7k
思路解释 创建三个字符数组,一个字符数组用来接收输入的字符串,一个只用来添加字符,一个只用来添加数字; 获取字符数组的长度,使用for循环判断已输入的数组的每个字符属于数字还是字符,将其分别添加到第一步中创建的数组中; 最后,再次使用for循环,将字符数组和数字字符数组中的内容添加到新数组中进行输出即可。 #include<iostream> #include<algorithm> #include<string.h> using namespace std; int main() { char s[105...
Sacan
2022年6月4日 18:32
O(n)
P1012
回复 0
|
赞 2
|
浏览 5.3k
#include <iostream> using namespace std; int main() { string str; getline(cin, str); string zimu = ""; string num = ""; for(int i = 0;i < str.size();i++){ if...
woshipzg123
2021年2月17日 14:05
C++用sort排序
P1012
回复 1
|
赞 3
|
浏览 10.2k
#include <iostream> #include <algorithm> using namespace std; bool cmp(char a,char b) { if(isdigit(a)==0&&isdigit(b)!=0) return 1; else return 0; } int main() { string s; cin>>s; sort(s.begin(),s.end(),cmp); cout<<s; retu...
蒋黎明
2022年3月18日 12:12
C++
P1012
回复 0
|
赞 0
|
浏览 5.7k
#include<bits/stdc++.h> using namespace std; struct node{ char c; int order; }; bool cmp(node a, node b){ if(isdigit(a.c) && isdigit(b.c)){ return a.order < b.order; &n...
1
2
3
4
5
6
题目
字符移动
题解数量
52
发布题解
在线答疑
热门题解
1
字符移动 题解:
2
字符移动 题解:C
3
字符移动 题解:
4
字符移动 题解:简洁版
5
字符移动 题解:
6
字符移动 题解:
7
字符移动 题解:
8
字符移动 题解:
9
题解:字符移动
10
字符移动 题解: