首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
nicooy
2024年2月19日 17:07
字符移动 题解:简单解法
P1012
回复 0
|
赞 0
|
浏览 1.4k
#include<iostream> #include<string> using namespace std; int main(){ string a; cin>>a; auto it=a.begin(); for(int i=0;i<a.length();i++){ if(isdigit(*it)){ ...
linlan
2024年1月21日 21:54
字符移动 题解:
P1012
回复 0
|
赞 3
|
浏览 1.2k
1. 不要额外的数组来存放数字等 2. 定义st状态数组,记录s中为数字的位置 3. 打印:根据st数组,首先打印非数字字符,然后再打印数字字符 #include<bits/stdc++.h> using namespace std; int st[110]; int main(){ string s; cin >> s; int len = s.size(); for (int i = 0; i < l...
Apricityxx
2023年10月25日 18:32
字符移动 题解:
P1012
回复 0
|
赞 1
|
浏览 1.3k
// // 字符移动.cpp // Algorithm // // Created by Apricity on 2023/10/25. // #include<iostream> #include<cmath> #include<cstring> #include<algorithm> #include<queue> using namespace std; int main(){ ...
活着的传奇
2023年8月15日 16:28
字符移动 题解:
P1012
回复 0
|
赞 0
|
浏览 1.3k
做麻烦了。先把数字存进一个b数组,然后把再把非数字的存入另外一个c数组,然后输出即可。 #include<bits/stdc++.h> using namespace std; bool shuzi(char c){ if(c>='0'&&c<='9'){ return 0; } else return 1; } int main(){ char s[100];char b[10];int d=0; int n=0;char c[10]; int e=0; ...
928上岸梦校!
2023年8月11日 09:59
字符串加法
P1012
回复 0
|
赞 1
|
浏览 1.2k
#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
|
浏览 1.3k
先输出非数字,将数字存入字符串,后再将数字字符串输出,注意字符串的范围,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
|
浏览 1.2k
#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
|
浏览 1.4k
使用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
|
浏览 3.0k
#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
|
浏览 5.2k
#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; ...
1
2
3
4
5
6
题目
字符移动
题解数量
56
发布题解
在线答疑
热门题解
1
字符移动 题解:
2
字符移动 题解:C
3
字符移动 题解:
4
字符移动 题解:
5
字符移动 题解:简洁版
6
字符移动 题解:
7
字符移动 题解:
8
字符移动 题解:
9
字符移动 题解:
10
题解:字符移动