社区讨论

B3654输入求调!!!

题目总版参与者 2已保存回复 4

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
4 条
当前快照
1 份
快照标识符
@m0hmsnr4
此快照首次捕获于
2024/08/31 12:17
2 年前
此快照最后确认于
2025/11/04 21:57
4 个月前
查看原帖

我的代码总是把单个字母或数字(不包含0)的输入当成0! 怎么办啊啊啊啊啊!!

CPP
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s,ans[10010];
    int num=1;
    bool c=true;
    while(1) {
        cin>>s;
        if(s.size()==1 && s[1]==0) {
            for(int i=1;i<=num;i++) {
                cout<<ans[i];
            }
            return 0;
        }
        for(int i=1;i<=num;i++) {
            if(ans[i]==s) {
                c=false;
                continue;
            }
        }
        if(c==true) {
            ans[num]=s;
            num++;
        }
        c=true;
    }
    return 0;
}

回复

4 条回复,欢迎继续交流。

正在加载回复...