关注
#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
相关推荐
03-29 05:26
门头沟学院 Java 点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 烂工作和没工作哪个更痛苦? #
3610次浏览 83人参与
# 牛油的搬砖plog #
189689次浏览 1279人参与
# 厦门银行科技岗值不值得投 #
16788次浏览 404人参与
# AI替代不了什么? #
3938次浏览 60人参与
# 发工资后,你做的第一件事是什么 #
100669次浏览 342人参与
# 给工作过的公司写一条大众点评,你会怎么写? #
1797次浏览 30人参与
# 春招至今,你收到几个面试了? #
6735次浏览 95人参与
# 学历VS实习,哪个更重要? #
13411次浏览 195人参与
# 实习心态崩了 #
111352次浏览 566人参与
# 一人分享一道面试手撕题 #
115120次浏览 2929人参与
# OPPO笔试 #
23355次浏览 104人参与
# 谈薪时HR压价该怎么应对 #
294323次浏览 3362人参与
# 工作上你捅过哪些篓子? #
69415次浏览 337人参与
# 产品人求职现状 #
361795次浏览 2604人参与
# 机械校招之路总结 #
120394次浏览 2084人参与
# 面试紧张时你会有什么表现? #
36100次浏览 246人参与
# 你的实习什么时候入职 #
368518次浏览 2372人参与
# uu们,春招你还来吗? #
71148次浏览 956人参与
# 面试中,你被问过哪些奇葩问题? #
100147次浏览 1453人参与
# 刚工作的你,踩过哪些坑? #
33712次浏览 278人参与
# 牛友的志愿填报指南 #
64108次浏览 494人参与