Advertisement
Guest User

Untitled

a guest
May 24th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<cstdlib>
  4. #include<time.h>
  5.  
  6. using namespace std;
  7.  
  8. int R1[100];
  9. int C1[100];
  10. int V1[100];
  11.  
  12. int n,m,k;
  13.  
  14. int read_data()
  15. {
  16. fstream f;
  17. f.open("input.dat",ios::in);
  18. f>>n>>m>>k;
  19. f.close();
  20. return 0;
  21. }
  22.  
  23. int fill_data()
  24. {
  25. srand(time(0));
  26. for(int i=0;i<k;i++)
  27. {
  28. V1[i]=rand()%100;
  29. int admis=1;
  30. do {
  31. R1[i]=rand()%n;
  32. C1[i]=rand()%m;
  33. for(int j=0;j<i;j++)
  34. if ( (R1[j]==R1[i])&&(C1[j]==C1[i]) ) admis=0;
  35. } while (!admis);
  36. }
  37. return 0;
  38. }
  39.  
  40. int fill_data()
  41. {
  42. int decidable[100][100];
  43. // Sa utilizez "decidable" ca matrice caracteristica ! Ura !
  44. // Deci : Daca decidable[i][j]=0 inseamna ca (i,j)
  45. // Nu a fost folosita !
  46. // Daca decidable[i][j]=1 inseamna ca (i,j)
  47. // a fost folosita !! Si deci nu sunt admisibile !!!!
  48. srand(time(0));
  49. for(int i=0;i<k;i++)
  50. {
  51. V1[i]=rand()%100;
  52. int admis=1;
  53. do {
  54. R1[i]=rand()%n;
  55. C1[i]=rand()%m;
  56.  
  57. // for(int j=0;j<i;j++)
  58. if ( (R1[j]==R1[i])&&(C1[j]==C1[i]) ) admis=0;
  59. } while (!admis);
  60. }
  61. return 0;
  62. }
  63.  
  64.  
  65. int print_data(int no1[],int no2[],int no3[],int dim)
  66. {
  67. for(int i=0;i<dim;i++)
  68. {
  69. cout<<endl<<"("<<R1[i]+1<<","<<C1[i]+1<<")="<<V1[i];
  70. }
  71.  
  72.  
  73. return 0;
  74. }
  75.  
  76.  
  77.  
  78. int main()
  79. {
  80. read_data();
  81. fill_data();
  82. print_data(R1,C1,V1,k);
  83.  
  84. return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement