Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- #include <time.h>
- #include <algorithm>
- using namespace std;
- ofstream fout("data.out");
- int a=0,b=30; /// capetele intervalului perechilor
- int cnt=500, poz=0;
- int sorted=0;
- struct pereche{
- int x, y;
- } p[200001];
- int cmp(pereche p, pereche q){
- return ((p.x<q.x) || (p.x==q.x && p.y<q.y));
- }
- int main()
- {
- srand(time(0));
- while(poz<cnt){
- p[poz].x = rand()%(b-a)+a;
- p[poz].y = rand()%(b-a)+a;
- int gasit=0;
- for(int i=0; i<poz && !gasit; i++)
- {
- if (p[i].x==p[poz].x && p[i].y==p[poz].y)
- {
- gasit=1;
- }
- }
- if (!gasit) {
- poz++;
- }
- }
- if (sorted) sort(p,p+cnt,cmp);
- for(int i=0; i<cnt; i++)
- fout << p[i].x << ' ' << p[i].y << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement