Advertisement
Guest User

Untitled

a guest
Nov 14th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int i, n = 0;
  9. cout << "Iveskite masyvo dydi " << endl;
  10. while(true){
  11. cin >> n;
  12. if(n < 0 || n >= 20){
  13. cout << "masyvo dydys yra intervale [1..20]" << endl;
  14. continue;
  15. }
  16. else{
  17. break;
  18. }
  19. }
  20.  
  21. int mas[n];// masyvo formavimas
  22. cout << "Iveskite elementus" << endl;
  23. for(int i = 0; i < n; i++){
  24. int n;//elementai
  25. cin >> n;
  26. mas[i] = n;
  27. }
  28. cout << "==================" << endl;
  29. //skaidres
  30. int temp;
  31. for (int i=0; i<n; i++)
  32. {
  33. for(int j=i; j<n; j++)
  34. {
  35. if(mas[i]<mas[j])
  36. {
  37. temp=mas[i];
  38. mas[i]=mas[j];
  39. mas[j]=temp;
  40. }
  41. }
  42. cout << mas[i] << endl;
  43.  
  44. }
  45. cout << "==================" << endl;
  46. if (n%2==1){
  47. for(i=n/2; i<n-1; i++)
  48. {
  49. mas[i]=mas[i+1];
  50. }
  51. mas[n-1]=0;
  52. n--;
  53. cout << "masyvas po salinimo" <<endl;
  54. for (int i=0;i<n;i++){
  55. cout << mas[i] << endl;
  56. }
  57. else {
  58. for(int j=i; j<n; j--)
  59.  
  60. }
  61. cout << mas[i] << endl;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement