Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- for(int i=0;i<3;i++)
- {
- int nums;
- cin>>nums;
- int arr[101];
- for(int num=0;num<nums;num++)
- {
- cin>>arr[num];
- }
- int *p=arr;
- bool forward=true;
- for(int many=nums;many>=1;many--)
- {
- if(forward)
- {
- for(int i=0;i<many;i++)
- {
- cout<<*p<<' ';
- p++;
- }
- p--;
- forward=false;
- }
- else if(!forward)
- {
- for(int i=0;i<many;i++)
- {
- cout<<*p<<" ";
- p--;
- }
- p++;
- forward=true;
- }
- cout<<endl;
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement