代码求调

CF20A BerOS file system

Wrong Answer.wrong answer 1st words differ - expected: '/a/b/c', found: '/a/b/c/'
by DPG_DPG123 @ 2023-06-18 14:55:50


```cpp # include <bits/stdc++.h> using namespace std; int main(){ string a; cin >> a; while(a[a.length()-1]=='/'&&a.length()>1)a=a.substr(0,a.length()-1); bool flag = 0; for (int i = 0;i < a.length();i++){ if(flag){ if(a[i] != '/'){ cout << a[i]; flag = 0; } }else{ cout << a[i]; if(a[i] == '/')flag = 1; } } return 0; } ``` 在代码前加上 ```cpp while(a[a.length()-1]=='/'&&a.length()>1)a=a.substr(0,a.length()-1); ``` 去掉尾巴上的/ 求关
by zhanghx0219 @ 2023-06-18 16:07:59


|