Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BARRAZVANALEXANDRU@CNSAMUILVULCAN.RO 07774074731
- SIII
- 1.
- #include <iostream>
- using namespace std;
- void imog(int x, int y, int &rez)
- {
- int a=0,b=0,c,p=1;
- while(x!=0)
- {
- c=x%10;
- x=x/10;
- if(c%2==1)
- {
- a=a*10+c;
- }
- }
- while(y!=0)
- {
- c=y%10;
- y=y/10;
- if(c%2==1)
- {
- b=c*p+b;
- p=p*10;
- }
- }
- if(a==b)
- rez=1;
- else
- rez=0;
- }
- int main() {
- int x,y,rez;
- cin>>x>>y;
- imog(x,y,rez);
- cout<<rez;
- return 0;
- }
- 2.
- #include <iostream>
- using namespace std;
- int main() {
- int n, k, a[21][21], i, j;
- cin>>n>>k;
- for(i=1; i<=n; i++)
- for(j=1; j<=n; j++)
- cin>>a[i][j];
- int aux;
- for(i=1; i<k; i++)
- { aux=a[i][k];
- a[i][k]=a[k][i];
- a[k][i]=aux;
- }
- for(i=1; i<=n; i++)
- { for(j=1; j<=n; j++)
- cout<<a[i][j]<<' ';
- cout<<endl;
- }
- return 0;
- }
- VAR I
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main() {
- ofstream cout("bac.out");
- int a,b,c,d;
- cin>>b>>c;
- d=c-b;
- cout<<c<<" "<<b<<" ";
- while(d!=2)
- {
- d=d-2;
- a=b-d;
- c=b;
- b=a;
- cout<<a<<" ";
- }
- cout.close();
- return 0;
- }
- /*
- Programul e eficient dpv al memoriei deoarece foloseste doar 4 variabile intregi
- simple.Acesta e eficient dpv al timpului deoarece are o complexitate O(log2(y)),
- unde y e ultimul termen din sirul dat. */
- VAR II
- int main() {
- int a,b,c,n;
- cin>>b>>c;
- cout<<c<<" "<<b<<" ";
- n=(c-b)/2;
- while(n>1){
- n--;
- a=b-2*n;
- cout<<a<<" ";
- c=b;
- b=a;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement