Pagini recente » Profil alex_cls7 | Profil arionboss | Cod sursa (job #2070725)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream in("tije.in");
ofstream out("tije.out");
vector <pair <int, int> > sol;
string s;
void add(int x)
{
string aux;
while(x > 0)
{
aux += (char)(x % 10 + '0');
x = x / 10;
}
s += aux;
}
int main()
{
int n;
in >> n;
int last = n + 1;
n--;
for(int i = n; i >= 1; i--)
{
for(int j = n + 1; j >= 1; j--)
for(int k = 1; k <= i; k++)
sol.push_back(make_pair(j, j + 1));
for(int j = 1; j <= i; j++)
sol.push_back(make_pair(last, 1));
}
for(auto it : sol)
{
add(it.first);
s += " ";
add(it.second);
s += "\n";
}
out << s;
return 0;
}