题解:P10397 『STA - R5』5k.sync.closer

一道十分简单的题。

我们观察发现,std::freopen 语句前必定会有 std::freopen(", 而它以后一直到下一个引号就是文件名,可以用 while 循环找出。

代码:

#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
    int t;
    cin >> t;
    while(t --){
        char a = 34;//引号的ASCLL码
        string ans;
        cin >> s;
        int i = 14;//std::freopen(" 长15个字符,而字符串是从0开始的,要减1
        while(s[i] != a){
            ans += s[i];
            i ++;
        }
        cout << ans << "\n";
    }
    return 0;
}

posted on 2024-05-02 20:38  zhangzirui66  阅读(9)  评论(0)    收藏  举报  来源

导航