Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int i, n = 0;
- cout << "Iveskite masyvo dydi " << endl;
- while(true){
- cin >> n;
- if(n < 0 || n >= 20){
- cout << "masyvo dydys yra intervale [1..20]" << endl;
- continue;
- }
- else{
- break;
- }
- }
- int mas[n];// masyvo formavimas
- cout << "Iveskite elementus" << endl;
- for(int i = 0; i < n; i++){
- int n;//elementai
- cin >> n;
- mas[i] = n;
- }
- cout << "==================" << endl;
- //skaidres
- int temp;
- for (int i=0; i<n; i++)
- {
- for(int j=i; j<n; j++)
- {
- if(mas[i]<mas[j])
- {
- temp=mas[i];
- mas[i]=mas[j];
- mas[j]=temp;
- }
- }
- cout << mas[i] << endl;
- }
- cout << "==================" << endl;
- if (n%2==1){
- for(i=n/2; i<n-1; i++)
- {
- mas[i]=mas[i+1];
- }
- mas[n-1]=0;
- n--;
- cout << "masyvas po salinimo" <<endl;
- for (int i=0;i<n;i++){
- cout << mas[i] << endl;
- }
- else {
- for(int j=i; j<n; j--)
- }
- cout << mas[i] << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement