Advertisement
rotti321

Test 111 2021 SIII

May 24th, 2021
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. BARRAZVANALEXANDRU@CNSAMUILVULCAN.RO    07774074731
  2.  
  3.  
  4. SIII
  5. 1.
  6. #include <iostream>
  7. using namespace std;
  8.  
  9. void imog(int x, int y, int &rez)
  10. {
  11.     int a=0,b=0,c,p=1;
  12.     while(x!=0)
  13.     {
  14.         c=x%10;
  15.         x=x/10;
  16.         if(c%2==1)
  17.          {
  18.            a=a*10+c;  
  19.          }
  20.     }
  21.     while(y!=0)
  22.     {
  23.         c=y%10;
  24.         y=y/10;
  25.         if(c%2==1)
  26.         {
  27.             b=c*p+b;
  28.             p=p*10;
  29.         }
  30.     }
  31.     if(a==b)
  32.       rez=1;
  33.     else
  34.       rez=0;
  35. }
  36. int main() {
  37.   int x,y,rez;
  38.   cin>>x>>y;
  39.   imog(x,y,rez);
  40.   cout<<rez;
  41.   return 0;
  42. }
  43.  
  44. 2.
  45. #include <iostream>
  46. using namespace std;
  47.  
  48. int main() {
  49.   int n, k, a[21][21], i, j;
  50.   cin>>n>>k;
  51.   for(i=1; i<=n; i++)
  52.     for(j=1; j<=n; j++)
  53.         cin>>a[i][j];
  54.   int aux;      
  55.   for(i=1; i<k; i++)
  56.     { aux=a[i][k];
  57.         a[i][k]=a[k][i];
  58.         a[k][i]=aux;
  59.     }
  60.   for(i=1; i<=n; i++)
  61.    { for(j=1; j<=n; j++)      
  62.         cout<<a[i][j]<<' ';
  63.     cout<<endl;
  64.    }
  65.   return 0;
  66. }
  67.  
  68.  
  69. VAR I
  70.  
  71. #include <iostream>
  72. #include <fstream>
  73. using namespace std;
  74.  
  75. int main() {
  76.     ofstream cout("bac.out");
  77.     int a,b,c,d;
  78.     cin>>b>>c;
  79.     d=c-b;
  80.     cout<<c<<" "<<b<<" ";
  81.    
  82.     while(d!=2)
  83.     {
  84.        d=d-2;
  85.        a=b-d;
  86.        c=b;
  87.        b=a;
  88.        cout<<a<<" ";
  89.     }
  90.     cout.close();
  91.   return 0;
  92. }
  93. /*
  94.   Programul e eficient dpv al memoriei deoarece foloseste doar 4 variabile intregi
  95.   simple.Acesta e eficient dpv al timpului deoarece are o complexitate O(log2(y)),
  96.   unde y e ultimul termen din sirul dat. */
  97.  
  98.  
  99. VAR II
  100.   int main() {
  101.    int a,b,c,n;
  102.    cin>>b>>c;
  103.    cout<<c<<" "<<b<<" ";
  104.    n=(c-b)/2;
  105.    while(n>1){
  106.        n--;
  107.        a=b-2*n;
  108.        cout<<a<<" ";
  109.        c=b;
  110.        b=a;
  111.    }
  112. }
  113.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement