zoukankan      html  css  js  c++  java
  • [蓝桥杯]错误票据

    题目:http://oj.ecustacm.cn/problem.php?id=1423

    这道题不难,就是输入要稍加费点力。

    推荐博客:https://www.cnblogs.com/Simon-X/p/5302627.html (在输入时,利用了输入到文件末尾结束。因为题目没有要求多组测试用例)

    我的思路:直接开一个数组用来记录数据出现的次数,有就加1,断号的值为0,重复的值为2,然后遍历一遍就能找出,

    #include <iostream>
    #include <cstring> 
    #include <cstdio>
    #include <string> 
    
    using namespace std;
    
    const int L = 100009;
    
    int data[L],N,s,e, m,n; 
    char ch;
    int num;
    
    void init() {
        for (int i = 0; i < L; i++) {
            data[i] = 0;
        }
        e = 0,s = L;
    }
    
    void parseLine(string & line) {
        int num = 0;
        line = line + " ";
        for (int i = 0; i < line.size(); i++) {
            if (line[i] >= '0' && line[i] <= '9') {
                num = num*10+(line[i]-'0');
            } else {
                if (num > 0) {
                    data[num]++;
                    if (s > num) s = num;
                    if (e < num) e = num;
                }
                num = 0;
            }
        }
    }
    
    int main() {
        
        string line;
        while(~scanf("%d", &N)) {
            init();
            // 获取N行的数据 
            N += 1; // 吸收第一个回车符 
            while(N--) {
                getline(cin, line);
                parseLine(line);
            }
            
            for (int i = s; i <= e; i++) {
                if (data[i] == 0) m = i;
                if (data[i] == 2) n = i;
            } 
            printf("%d %d
    ", m, n);
        }
    
        return 0;
    }

    。。。

  • 相关阅读:
    EF 使用 oracle
    mysql安装笔记
    解决问题
    第四次冲刺
    第三次冲刺
    SQA
    第二次冲刺
    第一次冲刺,求进步
    Scrum _GoodJob
    我对git 、github的初印象
  • 原文地址:https://www.cnblogs.com/hello-dummy/p/12775919.html
Copyright © 2011-2022 走看看