Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "iostream"
- using namespace std;
- int f1(int *a, short i)
- {
- int g=0;
- int k=a[0];
- for(short j=1;j<i;j++)
- if(k<a[j])
- {
- k=a[j];
- g=j;
- }
- return g;
- }
- void f2(int *a, short i)
- {
- int k1=0,k2=0;
- short j=0;
- for(j=0;j<i;j++)
- if(a[j]==0)
- {k1=j;goto end1;}
- cout<<"\nNo \"0\" elements.";goto end;
- end1:
- for(j=k1+1;j<i;j++)
- if(a[j]==0)
- {k2=j;goto end2;}
- end2:
- if((k1+1)<k2)
- {
- k1+=1;int s=1;
- for(;k1<k2;k1++)
- s=s*a[k1];
- cout<<"\ns="<<s;
- }
- else
- cout<<"\nOnly 1 \"0\" element, or 2 \"0\" elements on adjacent positions";end:
- if(i%2==0)
- for(int h,j=1;j<i/2;j+=2)
- {
- h=a[j];
- a[j]=a[i-1-j];
- a[i-1-j]=h;
- }
- else
- for(int h,j=1;j<i/2+1;j+=2)
- {
- h=a[j];
- a[j]=a[i-j];
- a[i-j]=h;
- };
- end4:
- cout<<'\n';
- for(j=0;j<i;j++)
- {
- cout<<' '<<a[j];
- };
- }
- void main()
- {
- int i;
- cout<<"\nEnter size. Under 100:";
- again:
- cin>>i;
- if(i>100||i<=0)
- {cout<<"\nError. Try again.";goto again;}
- int a[100];
- for(int j=0;j<i;j++)
- cin>>a[j];
- cout<<'\n'<<f1(a,i);
- f2(a,i);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement