本文最后更新于 1163 天前,其中的信息可能已经有所发展或是发生改变。
代码语言:javascript复制#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
vector<string> v;
vector<int> vc;
int str2int(string s){
int res=0;
int len = s.length();
for(int i=0;i<len;i ){
res = (s[i]-'0')*pow(10,len-i-1);
}
return res;
}
int main(){
string s;
int n;
cin>>n;
int m=n;
cin.ignore();
while(n--){
getline(cin,s);
v.push_back(s);
}
for(int i=0;i<m;i ){
string temp = v[i];string str="";
for(int j=0;j<temp.length();j ){
/*if(j==temp.length()-1){
if(temp[j]==' ')
vc.push_back(str2int(str));
else
}*/
if(temp[j]==' '){
vc.push_back(str2int(str));
str="";
}
else{
str =temp[j];
}
}
vc.push_back(str2int(str));
}
sort(vc.begin(),vc.end());
int dID,cID;int f=vc[0];
for(int i=1;i<vc.size();i ){
if(vc[i]-vc[i-1]==2)
dID = vc[i]-1;
else if((vc[i]==vc[i-1]))
cID = vc[i];
}
cout<<dID<<" "<<cID<<endl;
return 0;
}
Post Views: 201