Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I.
- 1.d
- 2.b
- 3.c
- 4.a
- 5.b
- II.
- 1.
- a)
- 1 27545
- b)
- 78 75
- c)
- #include<iostream>
- using namespace std;
- int main()
- {int n,c1,c2,s;
- cin>>n;
- c1=n%10;
- n/=10;
- c2=n%10;
- if(c1==c2)
- s=0;
- else
- if(c1>c2)
- s=1;
- else
- s=-1;
- do
- {c1=n%10;
- n/=10;
- c2=n%10;
- }while((c1-c2)*s<=0);
- cout<<s<<" "<<n;
- }
- d)
- #include<iostream>
- using namespace std;
- int main()
- {int n,c1,c2,s;
- cin>>n;
- c1=n%10;
- n/=10;
- c2=n%10;
- if(c1==c2)
- s=0;
- else
- if(c1>c2)
- s=1;
- else
- s=-1;
- c1=n%10;
- n/=10;
- c2=n%10;
- while((c1-c2)*s<0)
- {c1=n%10;
- n/=10;
- c2=n%10;
- }
- cout<<s<<" "<<n;
- }
- 2.
- struct cerc
- {int x,y,raza;}fig;
- 3.
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- { char s[101],p;
- cin>>s;
- for(p=0;p<=strlen(s)-1;p++)
- if(p==0)
- {if(s[p]=='A' && s[p+1]=='I')
- strcpy(s+p,s+p+1);}
- else
- if(s[p]=='A' && (s[p-1]=='I' || s[p+1]=='I'))
- strcpy(s+p,s+p+1);
- cout<<s;
- return 0;
- }
- III.
- 1.
- int factori(int x,int y)
- {int d=2,p=0,c=0,ok1,ok2;
- while(x!=1)
- {while(x%d==0)
- {x=x/d;
- ok1=1;}
- while(y%d==0)
- {y=y/d;
- ok2=1;}
- if(ok1==1 && ok2==1)
- {c++;
- ok1=0;
- ok2=0;}
- else
- {ok1=0;
- ok2=0;}
- d++;
- }
- return c;
- }
- 2.
- #include <iostream>
- using namespace std;
- int a[21][21];
- int main()
- {int n,i,j;
- cin>>n;
- for(i=1;i<=n;i++)
- {a[i][1]=n-i;
- a[n][n-i+1]=n-i;
- for(j=2;j<=n-i;j++)
- {a[i][j]=a[i][j-1]-1;
- a[n-j+1][n-i+1]=a[i][j];}}
- for(i=1;i<=n;i++)
- {for(j=1;j<=n;j++)
- cout<<a[i][j]<<" ";
- cout<<"\n";}
- return 0;
- }
- 3.
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("bac.in");
- int main()
- {
- int x,x1,x2,p=0,ok=0;
- while(fin>>x)
- {p++;
- if(ok==0 && x<0)
- {x1=p;
- ok=1;}
- if(x<0)
- x2=p;
- }
- cout<<max(p-x1+1,x2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement