解题思路:
注意事项:
参考代码:
#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 人评分