Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n;
- double *mas=new double [n];
- double shift(int, double);
- int main()
- {
- cout << "enter n " << endl;
- cin >> n;
- for (int i=0; i<n; i++)
- cin >> mas[i];
- double t=mas[n-1];
- shift(n, t);
- for (int i=0; i<n; i++)
- cout << mas[i] << " ";
- return 0;
- }
- double shift(int a, double b)
- { if (n%2!=0)
- {
- for (int i=a-1; i>1; i-=2)
- mas[i]=mas[i-2];
- mas[0]=b;
- for (int i=0; i<a; i++)
- return mas[i];
- }
- else
- {
- for (int i=a-2; i>1; i-=2)
- mas[i]=mas[i-2];
- mas[0]=mas[a-2];
- for (int i=0; i<a; i++)
- return mas[i];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement