Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<stdio.h>
- #include<conio.h>
- #include<stdlib.h>
- #include<math.h>
- #include<fstream>
- #include<time.h>
- #define N 100
- using namespace std;
- int tab[1000][1000];
- void CreateGraph(){
- int i, j, k, maks;
- int nasycenie = 60;
- srand(time(NULL));
- maks = floor(N*N*nasycenie/100);
- k=0;
- while(k<maks){
- i = rand() %N + 1;
- j = rand() %N + 1;
- if((tab[i][j] == 0) && (i != j)){
- tab[i][j] = 1;
- tab[j][i] = 1;
- k+=2;
- }
- }
- }
- int main()
- {
- CreateGraph();
- fstream plik;
- plik.open("dane.txt", ios::out | ios::app);
- if(plik.good() == true){
- for(int i=1; i<=N; i++){
- for(int j=1; j<=N; j++)
- if(tab[i][j] == 1) plik << i << "\t" << j << endl;
- }
- plik.close();
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement