(Blue Bridge cup) Incorrect ticket for previous questions

Source: Internet
Author: User

(Blue Bridge cup) Incorrect ticket for previous questions
Previous exam errors ticket time limit: 1.0 s memory limit: 256.0 MBProblem description

A confidential organization issues a certain ticket and must withdraw it all at the end of the year.

Each ticket has a unique ID number. The IDS of all bills for the year are consecutive, but the IDS start to be randomly selected.

Due to the negligence of the staff, an error occurred when entering the ID number, resulting in an ID disconnection and another ID duplication.

Your task is to find the ID of the break number and the ID of the duplicate number through programming.

Assume that the part number cannot be generated in the largest and smallest part number.

Input Format

The program must first input an integer N (N <100) to indicate the number of subsequent data rows.

Then, N rows of data are read.

The Data Length of each row is unequal. It is a number of positive integers separated by spaces (not greater than 100) (not greater than 100000). Please note that there may be extra spaces in the row and at the end of the row, your program needs to be able to process these spaces.

Each integer represents an ID.

Output Format

The program must output one line, which contains two integers, m n, separated by spaces.

Where, m indicates the ID of the disconnected number, and n indicates the ID of the duplicate number.

Example input 1 2
5 6 8 11 9
10 12 9 sample output 1 7 9 sample input 2 6
164 178 108 109 180 155 141 159 104 182 179 118 137 184 115 124 125 129 168 196
172 189 127 107 112 192 103 131 133 169 158
128 102 110 148 139 157 140 195
185 152 135 106 123 173 122 136 174 191 145 116 151 143 175 120 161 134 162 190
149 138 142 146 199 126 165 156 153 193 144 166 170 121 171 132 101 194 187 188
113 130 176 154 177 120 117 150 114 183 186 181 100 163 160 167 147 198 111 119 105 sample output 2 120

 

Find a series of digital interrupt numbers and duplicate numbers.

Solution: Be sure to output the break number first in the output of the duplicate number, and the result will only output two numbers. The second step is to consider its output. The length of each input cannot be determined. Therefore, the string method is used to output the output and intercept it one by one. However, there will be extra spaces in the question, which should be handled.

For details, see the code.

 

#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;char ch[1010][10100];int num[101000];int main(){    int n,k;    while (~scanf("%d",&n))    {        k=0;        getchar();        for (int i=0; i<n; a="0;" for="" int="" j="0;" len="0;">='0'&&ch[i][j]<='9')                {                    a=a*10+ch[i][j]-'0';                }                if(ch[i][j]==' '&&ch[i][j-1]!=' ')                {                    num[k++]=a;                    //cout<<"a="<<a<<endl; a="0;" flag="0;" for="" i="1;" if="" int="">num[i-1]+1)            {                cout<<num[i]-1<<" for="" i="1;" if="" int="" pre="" return=""></num[i]-1<<"></a<<endl;></n;></algorithm></cstring></cstdio></iostream>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.