Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<cstdlib>
- #include<time.h>
- using namespace std;
- int R1[100];
- int C1[100];
- int V1[100];
- int n,m,k;
- int read_data()
- {
- fstream f;
- f.open("input.dat",ios::in);
- f>>n>>m>>k;
- f.close();
- return 0;
- }
- int fill_data()
- {
- srand(time(0));
- for(int i=0;i<k;i++)
- {
- V1[i]=rand()%100;
- int admis=1;
- do {
- R1[i]=rand()%n;
- C1[i]=rand()%m;
- for(int j=0;j<i;j++)
- if ( (R1[j]==R1[i])&&(C1[j]==C1[i]) ) admis=0;
- } while (!admis);
- }
- return 0;
- }
- int fill_data()
- {
- int decidable[100][100];
- // Sa utilizez "decidable" ca matrice caracteristica ! Ura !
- // Deci : Daca decidable[i][j]=0 inseamna ca (i,j)
- // Nu a fost folosita !
- // Daca decidable[i][j]=1 inseamna ca (i,j)
- // a fost folosita !! Si deci nu sunt admisibile !!!!
- srand(time(0));
- for(int i=0;i<k;i++)
- {
- V1[i]=rand()%100;
- int admis=1;
- do {
- R1[i]=rand()%n;
- C1[i]=rand()%m;
- // for(int j=0;j<i;j++)
- if ( (R1[j]==R1[i])&&(C1[j]==C1[i]) ) admis=0;
- } while (!admis);
- }
- return 0;
- }
- int print_data(int no1[],int no2[],int no3[],int dim)
- {
- for(int i=0;i<dim;i++)
- {
- cout<<endl<<"("<<R1[i]+1<<","<<C1[i]+1<<")="<<V1[i];
- }
- return 0;
- }
- int main()
- {
- read_data();
- fill_data();
- print_data(R1,C1,V1,k);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement