[JAVA] [2013 Waterloo Cup preliminary Java undergraduate Group B] [Error Bill]__java

Source: Internet
Author: User
Tags unique id ticket
Title: Error Ticket


A secret-related unit has issued some kind of bill and has to withdraw it at the end of the year.


Each ticket has a unique ID number. The ID number of all bills is continuous throughout the year, but the starting digit of the ID is randomly selected.


Because the staff negligence, in the entry ID number of a mistake occurred, resulting in a certain ID number, another ID number.


Your task is to programmatically identify the ID of the broken number and the ID of the heavy number.


Suppose the broken number cannot occur in the largest and most small.


Requires that the program first enter an integer N (n<100) to represent the number of subsequent rows of data.
Then read n rows of data.
The length of each row of data, is separated by a number of (no more than 100) positive integers (not greater than 100000)
Each integer represents an ID number.


Requires that the program output 1 lines, with two integers m n, separated by a space.
where m represents the Id,n ID of the number of broken numbers


For example:
User input:
2
5 6 8 11 9
10 12 9


The program output:
7 9




Again for example:
User input:
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 197
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


The program output:
105 120



Resource conventions:
Peak memory consumption (including virtual machines) < 64M
CPU Consumption < 2000ms




Please output strictly according to the requirements, do not superfluous print similar: "Please enter ..." Superfluous content.


All the code is placed in the same source file, after debugging, the copy is submitted to the source.
Note: Do not use package statements. Do not use jdk1.6 and the above version of the features.
Note: The name of the main class must be: main, otherwise it will be handled in an invalid code.


[Java]   View plain copy print? import java.util.scanner;      class main {        public static void sort (int num[], int n)  {            for  (int i = 0; i < n; i++)  {               for  (int  j = i + 1; j < n; j++)  {                    if  (Num[i] > num[j])  {                        int tmp = num[i];                        num[i] = num[j];                        num[j] = tmp;                    }                }           }        }          public static void  main (String[] args)  {           Scanner  Sc = new scanner (system.in);           int  n = sc.nextint ();           sc.nextline ();            int ID[] = new int[1000];    &NBSP;&NBsp;      int posinid = 0;               for  (int i = 0; i < n; i++)  {               string str  = sc.nextline ();                string tmp[] = str.split (" ");                for  (int j = 0; j < tmp.length; j++)  {                    id[posinid++] = integer.valueof (Tmp[j]);                }           }        &nBsp;   sort (Id, posinid);           //  for  (int i = 0; i < posinid; i++)  {            // system.out.print (id[i] +  " ");// DEBUG: print out           // }     

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.