主站
DreamJudge
院校信息
专业题库
模拟考试
机试真题
专业课程
讨论区
兑换中心
登录
注册
发布
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
LianG_nnuo
2022年11月11日 21:46
c
P1012
回复 0
|
赞 1
|
浏览 3.8k
#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.1k
思路解释 创建三个字符数组,一个字符数组用来接收输入的字符串,一个只用来添加字符,一个只用来添加数字; 获取字符数组的长度,使用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
|
浏览 4.7k
#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
|
浏览 9.4k
#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.2k
#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...
li_yi
2022年2月1日 18:39
小白,代码拙劣
P1012
回复 0
|
赞 1
|
浏览 5.2k
#include #include char a[100]; //存输入的 char b[100]; //存数字 char c [100]; //存其他的 int main(){ gets(a); int j=0,k=0,count=0; int len=strlen(a); for(int i=0;i=48 && a[i]<=57){ count++; b[j]=a[i]; j++; } els...
未央
2021年5月31日 22:50
1012 基于字符串讲解代码稍作修改
P1012
回复 0
|
赞 3
|
浏览 6.8k
#include <stdio.h> #include <string.h>//字符串相关函数的头文件 int main() { char s[105] = {0};//输入的字符串数组 char num[105] = {0};//数字数组 char other[105] = {0};//其他符号数组 scanf("%s", s);//字符串输入用%s 注意字符数组名字就相当于首...
杨德胜
2021年3月6日 22:15
P1012 解题思路分享
P1012
回复 0
|
赞 0
|
浏览 8.1k
#include <bits/stdc++.h> using namespace std; int main() { char s[105]={0}, c[105]={0}; char t; cin>>s; int len=strlen(s),cnt=0; for(int i=0; i<len; i++){ if((s[i]-'0')>=0 && (s[i]-'0')<=9){ c[cnt++]=s[i]; for(int j=i; j<len-1; j++){ ...
老猫
2021年1月12日 11:38
用两个字符串
P1012
回复 0
|
赞 0
|
浏览 7.6k
#include<iostream> #include <string> #include<cstdlib> using namespace std; int main() { string s1,s2="",s3=""; cin>>s1; int len=s1.size(); for(int i=0;i<len;i++) { if(s1[i]>='0'&&s1[i]<='9')//是数字 s2+=s1[i]; else s3+=s1[i]; ...
fanxi
2020年5月9日 17:04
只需遍历字符串将非数字输出,将数字保存到新数组,最后统一输出新数组即可
P1012
回复 0
|
赞 3
|
浏览 9.9k
#include <stdio.h> #include <string.h> int main() { char s[101]; gets(s); int n=strlen(s); char digits[101]; int cnt=0; for(int i=0;i<n;++i) { if...
1
2
3
4
题目
字符移动
题解数量
37
发布题解
热门题解
1
题解:字符移动
2
字符移动(双字符串合并—暴力)
3
字符移动 题解:
4
只需遍历字符串将非数字输出,将数字保存到新数组,最后统一输出新数组即可
5
1012 基于字符串讲解代码稍作修改
6
C++用sort排序
7
字符移动 题解:
8
字符移动
9
O(n)
10
C++