#include<iostream> #include<fstream> #include<vector> #include<algorithm> using namespace std; int 10
#include<iostream>#include<fstream>#include<vector>#include<algorithm>usingnamespaces...
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;
int gcd(int a, int b){
return (a%=b ? gcd(b,a) :b);
}
int main(){
ifstream cin("E:\\abc.txt");
vector<int> v;
for(int a,b;cin>>a>>b;)
v.push_back(gcd(a,b));
sort(v.begin(),v.end());
for(int i=0; i<v.size()-1;++i)
cout<<v[i]<<" ";
cout<<v.back()<<endl;} 展开
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;
int gcd(int a, int b){
return (a%=b ? gcd(b,a) :b);
}
int main(){
ifstream cin("E:\\abc.txt");
vector<int> v;
for(int a,b;cin>>a>>b;)
v.push_back(gcd(a,b));
sort(v.begin(),v.end());
for(int i=0; i<v.size()-1;++i)
cout<<v[i]<<" ";
cout<<v.back()<<endl;} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询