Jeżeli Twój kolega korzysta z pythona to masz marne szanse na wygraną. Natomiast spróbowałem wymyślić coś z random shuffle i mam taki kod:
#include<bits/stdc++.h>
using namespace std;vector<int>v(30, 0);int main(){srand(time(0));for(int i=0;i<30;i++)v[i]=i;random_shuffle(begin(v),end(v));for(int i=0;i<30;i++)cout<<i+1<<"-"<<v[i]+1<<"\n";}
Tylko jest on niestety dłuższy niż to co Ty wymyśliłeś, dlatego poniżej wklejam nieco krótszą wersję Twojego pomysłu:
#include<bits/stdc++.h>
using namespace std;int t[30];int main(){srand(time(0));for(int i=0;i<30;i++){int x=rand()%30;while(t[x])x=rand()%30;t[x]=1;cout<<i+1<<"-"<<x+1<<'\n';}}