danb1212

Untitled

Feb 16th, 2021
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 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 c1,c2,c3;
  13. int c[2][3]={1,2,3,4,5,6};
  14. do
  15. {
  16. if ( a[0][2] < a[1][2] )
  17. {
  18. //swap row 1 and row 2
  19. c[0,0] = a[0][0]; c[0,1] = a[0][1]; c[0][2] = a[0][2];
  20. a[0,0]= a[1][0]; a[0,1]= a[1][1] ; a[0,2]= a[1][2];
  21. a[1][0] = c[0,0]; a[1][1] = c[0,1]; a[1][2] = c[0,2];
  22. continue;
  23. }
  24.  
  25. // row 1 = row 1 - row 2
  26. printf("test1\n");
  27. 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];
  28.  
  29. for ( i = 0; i <= 1; i++ )
  30. {
  31. for ( j = 0; j <= 2; j++ )
  32. {
  33. printf("a[%d][%d] = %d\t", i,j, a[i][j] );
  34. }
  35. printf("\n");
  36. }
  37. } while( (a[0][2] - a[1][2]) != 0);
  38.  
  39. for ( i = 0; i <= 1; i++ )
  40. {
  41. for ( j = 0; j <= 2; j++ )
  42. {
  43. printf("a[%d][%d] = %d\t", i,j, a[i][j] );
  44. }
  45. printf("\n");
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment