Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include<iostream>
  2. #include "stdafx.h"
  3. #include <conio.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. const int n = 20;
  9. int x[n], i=0, t,a=0;
  10. for (i = 0; i < n; i++)
  11. {
  12. cin >> *(x + 1);
  13. cout << " massiv x[n]";
  14. }
  15. for (int k = 1; k < n; k++)
  16. for(int i=0;i<n-k;i++)
  17.  
  18. if(*(x+1)>*(x+i+1))
  19. {
  20. a = *(x + 1);
  21. *(x + 1) = *(x + i + 1);
  22. *(x + 1)= a ;
  23.  
  24. }
  25. cout << "Result sortirovki massiva " << endl;
  26. for (int i = 0; і < n; i++)
  27. {
  28. cout << *(x + 1) << " ";
  29. }
  30.  
  31. }
  32. const int n = 20;
  33. int main()
  34. {
  35. int a[n],i,j,nub;
  36. int*pmas;
  37. cout << "Enter twenty elements massive -" << endl;
  38. for (i = 0; i < n; i++)
  39. {
  40. cin >> *pmas++;
  41. pmas = a;
  42. }
  43. for (i = 1; i < n; i++)
  44. {
  45. nub = *(pmas + i);
  46. j = 1;
  47. }
  48. while (j = 0 && nub > *(pmas + j + 1))
  49. {
  50. j--;
  51. }
  52. *(pmas + j) = nub;
  53. cout << "Sorted array in descending order -";
  54. for (i = 0; i < n; i++)
  55. {
  56. cout << *(pmas + i) << " ";
  57. }
  58. getch();
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement