Advertisement
Cucura_Georgiana

Sesiunea iunie-iulie, 4 iulie 2019

Nov 11th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. Sesiunea iunie-iulie, 4 iulie 2019 (Incercari)
  2.  
  3. Subiect 3
  4. 1.  #include<iostream>
  5. using namespace std;
  6. void impare (int n, int& r)
  7. {
  8.     int p=1;
  9.     r=0;
  10.     while(n!=0)
  11.     {
  12.         r=r+n%10*p;
  13.         p=p*10;
  14.         if(n%10%2!=0)
  15.         {
  16.             r=r+(n%10-1)*p;
  17.         }
  18.         n=n/10;
  19.     }
  20. }
  21. int main()
  22. {
  23.     int n, r;
  24.     cin>>n;
  25.     impare(n, r);
  26.     cout<<r;
  27.     return 0;
  28. }
  29.  
  30. 2.  #include<iostream>
  31. using namespace std;
  32. int a[1001][1001];
  33. int main()
  34. {
  35.     int n, m, i, j, k, l;
  36.     cin>>m>>n;
  37.     for(i=1; i<=m; i++)
  38.     {
  39.         for(j=1; j<=n; j++)
  40.         {
  41.             cin>>a[i][j];
  42.         }
  43.     }
  44.     cout<<'\n';
  45.     for(i=1; i<=m; i++)
  46.     {
  47.         for(j=1; j<=n/2; j++)
  48.         {
  49.             cout<<a[i][j]<<" ";
  50.         }
  51.         cout<<'\n';
  52.     }
  53.     cout<<'\n';
  54.     for(k=1; k<=m; k++)
  55.     {
  56.         for(l=n; l>=n/2+2; l--)
  57.         {
  58.             cout<<a[k][l]<<" ";
  59.         }
  60.         cout<<'\n';
  61.     }
  62.     cout<<'\n';
  63.     if(a[i][j]==a[k][l])
  64.     {
  65.         cout<<"DA";
  66.     }
  67.     else
  68.     {
  69.         cout<<"NU";
  70.     }
  71.     return 0;
  72. }
  73.  
  74. 3.  #include<iostream>
  75. #include<fstream>
  76. using namespace std;
  77. ifstream fin("bac.in");
  78. int ap[1001];
  79. int main()
  80. {
  81.     int i, x, x_ant;
  82.     fin>>x_ant;
  83.     while(fin>>x)
  84.     {
  85.         if(x_ant>x)
  86.         {
  87.             ap[x_ant]++;
  88.             x_ant=x;
  89.         }
  90.     }
  91.     for(i=1; i<=1001; i++)
  92.     {
  93.         if(ap[i]!=0)
  94.         {
  95.             cout<<i<<" ";
  96.             ap[i]--;
  97.         }
  98.     }
  99.     return 0;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement