Guest User

Untitled

a guest
Jan 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. for(i = 0; (i < 9); i++)
  2. {
  3. for(j = 0; j < 9; j++)
  4. {
  5. //cout << " " << Matrix[i][j];
  6. //cout << "i: " << i << endl;
  7. if(Matrix[i][j] == 0)
  8. {
  9. //temp = 10;
  10. [goto] ;
  11. //break;
  12. }
  13. }
  14. }
  15.  
  16. int i,j;
  17. for(i = 0; i < 9; i++)
  18. {
  19. for(j = 0; j < 9; j++)
  20. {
  21. //cout << " " << Matrix[i][j];
  22. //cout << "i: " << i << endl;
  23. if(Matrix[i][j] == 0)
  24. {
  25. //temp = 10;
  26. goto end;
  27. //break;
  28. }
  29. }
  30. }
  31. end:
  32. cout << i << " " << j << endl;
  33.  
  34. for (/* ... */) {
  35. /* ... */
  36. if (/* ... */)
  37. goto finalise;
  38. }
  39. finalise:
  40. foo = bar; //...
  41.  
  42. inline std::pair<int,int> findZeroEntry(std::vector matrix) {
  43. for (int i = 0; i < 9; i++)
  44. for (int j = 0; j < 9; j++)
  45. if (Matrix[i][j] == 0)
  46. return std::make_pair(i,j);
  47. return std::make_pair(9,9); // error
  48. }
  49.  
  50. Matrix m;
  51. Index2D< 9, 9 > pos;
  52.  
  53. for( ; pos < pos.end(); ++pos )
  54. {
  55. if( m( pos.x(), pos.y() ) == 0 )
  56. {
  57. break;
  58. }
  59. }
  60. cout << pos.x() << " " << pos.y() << endl;
  61.  
  62. Matrix m;
  63. Index2D< 9, 9 > pos;
  64.  
  65. for( ; pos < pos.end(); ++pos )
  66. {
  67. if( m[pos] == 0 )
  68. {
  69. break;
  70. }
  71. }
  72. cout << pos.x() << " " << pos.y() << endl;
  73.  
  74. template< int width, int height >
  75. struct Index2D
  76. {
  77. int i_;
  78.  
  79. int x() const { return i_ % width; }
  80. int y() const { return i_ / width; }
  81.  
  82. void operator++() { ++i_; }
  83.  
  84. bool operator<( Index2D const& other ) const
  85. {
  86. return (i_ < other.i_);
  87. }
  88.  
  89. Index2D(): i_( 0 ) {}
  90.  
  91. Index2D( int const x, int const y )
  92. : i_( width*y + x )
  93. {}
  94.  
  95. static const Index2D endValue;
  96. static Index2D end() { return endValue; }
  97. };
  98.  
  99. template< int width, int height >
  100. Index2D< width, height > const Index2D< width, height >::endValue( 0, height );
  101.  
  102. bool HasFoundZero = false;
  103. for(i = 0; i < 9; i++)
  104. {
  105. for(j = 0; j < 9; j++)
  106. {
  107. //cout << " " << Matrix[i][j];
  108. //cout << "i: " << i << endl;
  109. if(Matrix[i][j] == 0)
  110. {
  111. //temp = 10;
  112. HasFoundZero = true;
  113. }
  114. if(HasFoundZero)
  115. {
  116. break;
  117. }
  118. }
  119. if(HasFoundZero)
  120. {
  121. break;
  122. }
  123. }
Add Comment
Please, Sign In to add comment