Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- ofstream g("bac.txt");
- int main()
- {
- int x,y,z,n,a[100],i,d1,d2,t=0,k;
- cin>>n;
- cin>>x;
- cin>>y;
- cin>>z;
- a[1]=x;
- a[2]=y;
- a[3]=z;
- d1=y-x;
- d2=z-y;
- if(n%2==1)
- {
- t=(n/2)*d2+(n/2)*d1+x;
- k=1;
- }
- else
- {
- t=(n/2-1)*d2+(n/2)*d1+x;
- k=0;
- }
- cout<<t<<" ";
- while(n>1&&k==0)
- {
- if(x==0)
- {
- x=1;
- t=t-d2;
- }
- else
- {
- x=0;
- t=t-d1;
- }
- cout<<t<<" ";
- n--;
- }
- while(n>1&&k==1)
- {
- if(x==0)
- {
- x=1;
- t=t-d1;
- }
- else
- {
- x=0;
- t=t-d2;
- }
- cout<<t<<" ";
- n--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment