题目描述
map直接进行存入[HTML_REMOVED],因为map的key自动排序,输出value
#include<bits/stdc++.h>
using namespace std;
int n;
map<double,string>mp;
void solve()
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
double key= 1.0 * i / j;
string value = to_string(i) + "/" +to_string(j);
if(!mp.count(key))
mp[key]=value;
}
}
cout<<"0/1"<<endl;
for(auto a: mp)
{
if(a.first<1)
cout<<a.second<<endl;
}
cout<<"1/1"<<endl;
}
int main()
{
cin>>n;
solve();
return 0;
}