ValerianBenchea

Bac 2018

Jun 20th, 2023
837
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. ///_____SUBIECTUL II 5_____
  2. #include <iostream>
  3. #include <cstring>
  4. using namespace std;
  5. int main()
  6. {
  7.     char s[101], c[101], b[101];
  8.     cin>>s>>c;
  9.     int i, loc=0, j;
  10.     if(strlen(s)!=strlen(c))
  11.         cout<<"cod incorect";
  12.     else
  13.     {
  14.         b[0]=s[0];
  15.         for(i=1; i<strlen(s); i++)
  16.         {
  17.             if(c[i]%2==0)
  18.             {
  19.                 loc++;
  20.                 for(j=loc; j>=1; j--)
  21.                     b[j]=b[j-1];
  22.                 b[0]=s[i];
  23.             }
  24.             else
  25.                 b[++loc]=s[i];
  26.         }
  27.         b[++loc]='\0';
  28.     }
  29.     cout<<b;
  30.     return 0;
  31. }
  32.  
  33. ///_____SUBIECTUL III 3_____
  34. int resturi(int n, int x, int y, int r)
  35. {
  36.     int i, cnt=0;
  37.     for(i=1; i<=n; i++)
  38.         if(i%x==r && i%y==r)
  39.             cnt++;
  40.     return cnt;
  41. }
  42.  
  43. ///_____SUBIECTUL III 4_____
  44. #include <iostream>
  45. #include <fstream>
  46. using namespace std;
  47. ifstream fin("bac.txt");
  48. int main()
  49. {
  50.     int a, b, c, lmax=-1, lc=0;
  51.     fin>>a>>b;
  52.     while(fin>>c)
  53.     {
  54.         if(a!=b && b!=c && a!=c)
  55.             lc++;
  56.         else
  57.             lc=0;
  58.         if(lc>lmax)
  59.             lmax=lc;
  60.         a=b;
  61.         b=c;
  62.     }
  63.     fout<<lmax+2;
  64.     fin.close();
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment