关注
#include <stdio.h>
#include <string.h>
int main()
{
char str[100];
char out[100][300];
int lon[100];
int r=0,k=0;
while(~scanf("%s",str)){
for(int i=0,len=strlen(str);i<len;i++)//拆分
{
if(str[i]>='1'&&str[i]<='9'){
if(str[i+1]<'1'||str[i+1]>'9'){//一位数字
memcpy(out[k++],&str[r],i-r+1);
r=i+1;
i=r;
}
else //两位数字
{
memcpy(out[k++],&str[r],i+1-r+1);
r=i+2;
i=r;
}
}
}
int len2;
char tm[50];
for(int i=0;i<k;i++){//lon录值
len2=strlen(out[i]);
for(int j=0;j<len2;j++){
if(out[i][j]>='1'&& out[i][j]<='9'){
if(len2-j==1)//一位数字
{
lon[i]=(int)out[i][j]-48;
out[i][j]='\0';
}
else
if(len2-j==2)
{
lon[i]=((int)out[i][j]-48)*10+(int)out[i][j+1]-48;
out[i][j+1]='\0';
out[i][j]='\0';
break;
}
}
}
}
int q;
char tmp[50];
for(int i=0;i<k;i++)
for(int h=0;h<k-1;h++){
if(lon[h]>lon[h+1]){
q=lon[h];
lon[h]=lon[h+1];
lon[h+1]=q;
memcpy(tmp,out[h],strlen(out[h]));
memset(out[h],0,strlen(out[h]));
memcpy(out[h],out[h+1],strlen(out[h+1]));
memset(out[h+1],0,strlen(out[h+1]));
memcpy(out[h+1],tmp,strlen(tmp));
memset(tmp,0,strlen(tmp));
}
}
for(int i=0;i<k;i++){
for(int g=0;g<lon[i];g++)
printf("%s",out[i]);
}
}
return 0;
}
我的第三题代码,自测通过,没时间做。。。。忧伤
查看原帖
点赞 2
相关推荐
点赞 评论 收藏
分享
查看5道真题和解析 点赞 评论 收藏
分享
点赞 评论 收藏
分享
05-12 15:20
三峡大学 大数据开发工程师 点赞 评论 收藏
分享
点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 26届春招投递记录 #
16573次浏览 117人参与
# Vibe Coding 会干掉初级岗位吗? #
51549次浏览 327人参与
# 我的求职总结 #
486075次浏览 6867人参与
# 美团秋招笔试 #
218868次浏览 1196人参与
# 27届实习投递记录 #
84787次浏览 904人参与
# 实习生应该准时下班吗 #
360481次浏览 1762人参与
# 职场吐槽大会 #
361326次浏览 2308人参与
# 面试常问题系列 #
311058次浏览 4803人参与
# 面试中的破防瞬间 #
1268733次浏览 11141人参与
# 我是XXX,请攻击我最薄弱的地方 #
95851次浏览 642人参与
# 拼多多工作体验 #
62743次浏览 439人参与
# 机械人还在等华为开奖吗? #
341996次浏览 1655人参与
# 华为工作体验 #
332306次浏览 1439人参与
# 牛油的搬砖plog #
207491次浏览 1336人参与
# 什么专业适合考公 #
73432次浏览 476人参与
# AI Coding实战技巧 #
32025次浏览 400人参与
# 实习工作,你找得还顺利吗? #
597327次浏览 6758人参与
# 求职遇到的搞笑事件 #
192879次浏览 962人参与
# 运营每日一题 #
147632次浏览 981人参与
# 小厂实习有必要去吗 #
95145次浏览 452人参与
