输出顺序不对!!
查看原帖
输出顺序不对!!
1382592
Lanhening楼主2024/11/6 20:50

输出

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
int n;
int gcd(int a,int b){
	if(b==0){
		return a;
	}
	if(a%b==0) return b;
	return gcd(b,a%b);
	if(gcd(a,b)==1) return 1;
	else return 0;
}
int main(){
	cin>>n;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(gcd(i,j)==1){
				if(i<=j){
				cout<<i<<"/"<<j<<endl;					
				}		
			}
		}
	}
	return 0;
}
2024/11/6 20:50
加载中...