Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. /*fdupp - two dimensional array duplicate search algorithm*/
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int user[5] [5];
  6.  
  7. void fdupp() {
  8.  
  9. bool flag;
  10. int count=0;
  11.  
  12. for(int r=0; r<5; r++) {
  13.  
  14. for(int c=0; c<5; c++) {
  15.  
  16. for(int outer=0; outer<5; outer++) {
  17.  
  18. for(int inner=0; inner<5; inner++) {
  19.  
  20. if((inner==c) && (outer==r)) continue;
  21.  
  22. else if(user[r] [c]==user[outer] [inner]) {
  23.  
  24. count++;
  25.  
  26. cout <<"\n " << user[r] [c] <<" located at row " << r <<" column " << c;
  27.  
  28. goto full_break;
  29. }
  30. }
  31. }
  32. full_break:;
  33.  
  34. }
  35. }
  36.  
  37. if(!(count)) cout <<"\n No duplicates found!";
  38. }
  39.  
  40.  
  41. int main() {
  42.  
  43. for(int loadr=0; loadr<5; loadr++) {
  44.  
  45. for(int loadc=0; loadc<5; loadc++) {
  46.  
  47. cout <<"\nValue for element " << loadr <<" " << loadc <<": ";
  48. cin >> user[loadr] [loadc];
  49.  
  50. }
  51. }
  52.  
  53. fdupp();
  54.  
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement