Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3.  
  4. using namespace std;
  5.  
  6. void bubbleSort(int tab[],int size)
  7. {
  8. for(int i=0;i<size;i++){
  9. for(int j=1;j<size-i;j++){
  10. if(tab[j-1]>tab[j]){
  11. swap(tab[j-1], tab[j]);
  12. }
  13.  
  14. }
  15.  
  16. }
  17.  
  18. }
  19.  
  20.  
  21.  
  22. int main(){
  23.  
  24. int option;
  25. cin >> option;
  26.  
  27.  
  28. switch(option){
  29.  
  30. case 1:{
  31. const int size = 6;
  32. double table[size];
  33.  
  34. for(int i = 0; i < size; i++){
  35. cin >> table[i];
  36.  
  37. while(table[i] <= 0 or table[i] >= 10){
  38. cin >> table[i];
  39. }
  40. }
  41. cout << "Resulting array: ";
  42.  
  43. for(int i = 0; i < size; i++){
  44. cout << table[i] << " ";
  45. }
  46.  
  47. }
  48. break;
  49.  
  50. case 2:{
  51.  
  52.  
  53. const int size = 5;
  54. int tab[size];
  55. int tab1[size];
  56.  
  57. for(int i=0;i<size;i++){
  58. cin>>tab[i];
  59. }
  60.  
  61. bubbleSort(tab, size);
  62.  
  63. for(int i=0;i<size;i++){
  64. cin>>tab1[i];
  65. }
  66.  
  67. bubbleSort(tab1, size);
  68.  
  69. int x = 0;
  70. for(int i=0;i<size;i++){
  71. if(tab[i] == tab1[i]){
  72. x= x + 1;
  73. }
  74. }
  75.  
  76. if(x == 5){
  77. cout << "Equal.";
  78. }
  79. else{
  80. cout << "Different.";
  81. }
  82.  
  83.  
  84. }
  85. break;
  86.  
  87.  
  88. case 3:{
  89. cout << "program 3" << endl;
  90. }
  91. break;
  92.  
  93. default:{
  94. cout << "Wrong task number." << endl;
  95. }
  96. break;
  97.  
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement