Answers for "array question 1"

0

array question 1

#include <iostream>
    using namespace std;
    int a[100],n,i,tempr,templ;
    int main()
    {
    cin>>n;
    for(i=1;i<=n;i++) cin >> a[i];
    for(i=1;i<=n;i++)
        {
            tempr = a[n];
            a[n] = a[i];
            a[i] = tempr;
            cout<<"Right: "<<a[i]<<endl;
        }
    for(i=1;i<=n;i++)
        {
            templ = a[2];
            a[2] = a[i];
            a[i] = templ;
            cout<<"Left: "<<a[i]<<endl;
        }
    return 0;
}
Posted by: Guest on June-07-2021

Browse Popular Code Answers by Language