danb1212

Untitled

Feb 16th, 2021
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int m,n,i,j;
  7. printf("Enter m,n: ");
  8. scanf("%d %d", &m, &n);
  9.  
  10. int a[2][3]= {{1, 0, m},
  11. {0, 1, n}};
  12. int c[2][3]={1,2,3,4,5,6};
  13. do
  14. {
  15. if ( a[0][2] < a[1][2] )
  16. {
  17. //swap row 1 and row 2
  18. c[0,0] = a[0][0]; c[0,1] = a[0][1]; c[0][2] = a[0][2];
  19. a[0,0]= a[1][0]; a[0,1]= a[1][1] ; a[0,2]= a[1][2];
  20. a[1][0] = c[0,0]; a[1][1] = c[0,1]; a[1][2] = c[0,2];
  21. continue;
  22. }
  23.  
  24. // row 1 = row 1 - row 2
  25. printf("test1\n");
  26. a[0][0]= a[0][0] - a[1][0]; a[0][1]=a[0][1] - a[1][1]; a[0][2]=a[0][2] - a[1][2];
  27.  
  28. for ( i = 0; i <= 1; i++ )
  29. {
  30. for ( j = 0; j <= 2; j++ )
  31. {
  32. printf("a[%d][%d] = %d\t", i,j, a[i][j] );
  33. }
  34. printf("\n");
  35. }
  36. } while( (a[0][2] - a[1][2]) != 0);
  37.  
  38. for ( i = 0; i <= 1; i++ )
  39. {
  40. for ( j = 0; j <= 2; j++ )
  41. {
  42. printf("a[%d][%d] = %d\t", i,j, a[i][j] );
  43. }
  44. printf("\n");
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment