Advertisement
Guest User

Test dla kierowcow zle

a guest
Nov 22nd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. using namespace std;
  5. int main() {
  6. int n,m;
  7. int an,am;
  8. srand (time(NULL));
  9.  
  10. cin >> n;
  11. cin >> m;
  12.  
  13. cout << endl;
  14. int tab[n][m];
  15. for (int i=1;i<=n;i++)
  16. {
  17. for(int j=1;j<=m;j++)
  18. {
  19. tab[i][j]=rand()%99+1;
  20. if (tab[i][j] >=10)
  21. {
  22. cout << tab[i][j] << " ";
  23. }
  24. else
  25. {
  26. cout << tab[i][j] << " ";
  27. }
  28.  
  29. }
  30. cout << endl;
  31. }
  32.  
  33.  
  34. an=rand()%n+1;
  35. am=rand()%m+1;
  36. cout << "wybrane n i m to: ";
  37. cout << an;
  38. cout << endl;
  39. cout << am;
  40. cout << endl;
  41. cout << "A ta wartosc to: ";
  42. //cout << tab[an][am];
  43. int c;
  44. c=tab[an][am];
  45. cout << endl;
  46. int tmp;
  47. for (int i=1;i<=n;i++)
  48. {
  49. for(int j=1;j<=m;j++)
  50. {
  51. if (tab[i][j]<tab[i][j+1])
  52. {
  53. tmp=tab[i][j+1];
  54. tab[i][j]=tab[i][j+1];
  55. tab[i][j+1]=tmp;
  56. }
  57. if (tab[i][j] >=10)
  58. {
  59. cout << tab[i][j] << " ";
  60. }
  61. else
  62. {
  63. cout << tab[i][j] << " ";
  64. }
  65. }
  66. cout << endl;
  67.  
  68. }
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75. return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement