求助
  • 板块P1597 语句解析
  • 楼主0010ss
  • 当前回复9
  • 已保存回复9
  • 发布时间2021/7/31 10:25
  • 上次更新2023/11/4 12:25:27
查看原帖
求助
518159
0010ss楼主2021/7/31 10:25

又又又来了

#include<iostream>
#include<cstring>
using namespace std;
char list1[256], temp[110], ans[3];
int main(){
    cin >> list1;
    memset(ans,0,sizeof(ans));
    int cnt = 0, m = strlen(list1);
    for(int i = 0; i < m; i+=5){
        temp[cnt] = list1[i];
        cnt += 2;
    }
    cnt = 1;
    for(int i = 3; i < m; i+=5){
        temp[cnt] = list1[i];
        cnt += 2;
    }
    cnt = 0;
    while(cnt < strlen(temp)){
        if('0' <= temp[cnt+1] && temp[cnt+1] <= '9'){
            ans[temp[cnt] - 'a'] = temp[cnt + 1] - '0';
        }else{
            ans[temp[cnt] - 'a'] = ans[temp[cnt + 1] - 'a'];
        }
        cnt+=2;
    }
    cout << ans[0] << " " << ans[1] << " " << ans[2];
    return 0;
}

老是卡在cin运行不下去,所以就TLE了,怎么解决,谢谢!

2021/7/31 10:25
加载中...