解题思路:
注意事项:
参考代码:
#include<iostream> using namespace std; int main() { int N; cin>>N; int a[100005]; int temp=0; // m表示断号id,n表示重号id int m,n; // 可以学习一下这个输入方式 while(N--){ while(cin>>a[temp]) { temp++; if(cin.get()=='\n'){ break; } } } // 对数组进行升序排序 int s; for (int i=0; i<temp-1; i++) { for (int j=0; j<temp-1-i; j++) { if (a[j] > a[j+1]) { s = a[j]; a[j] = a[j+1]; a[j+1] = s; } } } // 判断断号id for(int i=0;i<temp;i++){ if(a[i+1]!=a[i]+1&&a[i+1]!=a[i]){ m=a[i+1]-1; cout<<m<<' '; break; } } // 判断重号id for(int i=0;i<temp;i++){ if(a[i]==a[i+1]){ n=a[i]; cout<<n; break; } } return 0; }
0.0分
4 人评分
震宇大神的杀毒软件 (C++代码)浏览:1125 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:654 |
【蟠桃记】 (C语言代码)浏览:670 |
字符逆序 (C语言代码)浏览:462 |
蛇行矩阵 (C语言代码)浏览:515 |
A+B for Input-Output Practice (III) (C语言代码)浏览:428 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:705 |
C语言训练-求PI* (C语言代码)浏览:339 |
校门外的树 (C语言代码)浏览:591 |
开心的金明浏览:1579 |