Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. const int dim_mat = 501;
  6. const int dim = 60001;
  7.  
  8. ifstream f("numere9.in");
  9. ofstream g("numere9.out");
  10.  
  11. void afiseaza_matricea( int a[ dim_mat ][ dim_mat ], int n )
  12. {
  13. int i, j;
  14. for( i = 1; i <= n; ++i )
  15. {
  16. for( j = 1; j <= n; ++j )
  17. g << a[ i ][ j ] << ' ';
  18. g << '\n';
  19. }
  20. g << "\n\n";
  21. }
  22.  
  23. bool v[60001];/// initializeaza cu 0 <=> False
  24.  
  25. int main()
  26. {
  27. int x,i,j,n, max = 0, min = dim_mat, cnt0 = 0, start1;
  28. f >> n;
  29. ///v = new bool[ n * n + 1];
  30.  
  31.  
  32. for(i=1;i<=n;i++)
  33. for(j=1;j<=n;j++)
  34. {
  35. f >> x;
  36. if( x == 0 )
  37. ++cnt0;
  38. if(x != 0 && x < 60001)
  39. v[ x ] = 1;
  40. }
  41.  
  42.  
  43.  
  44. i = 1;
  45. while( v[ i ] != 0 )
  46. ++i;
  47. start1 = i;
  48.  
  49. /*for(i=1;i<=n*n;i++)
  50. {
  51. if( v[i] == 0 )
  52. {
  53. if( i >= max ) max=i;
  54. if( i <= min ) min=i;
  55. }
  56. }
  57. g << min << " "<<max << endl;*/
  58. g << start1 <<" "<< start1 + cnt0 - 1 << endl;
  59.  
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement