ValerianBenchea

Bac 2020

Jun 22nd, 2023 (edited)
780
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. ///_____SUBIECTUL III 1_____
  2. int suma(int a, int b)
  3. {
  4.     int s=1, i;
  5.     if(b>a)
  6.         swap(a, b);
  7.     for(i=2; i<=a; i++)
  8.         if(a%i==0 && b%i==0)
  9.             s+=i;
  10.     return s;
  11. }
  12.  
  13. ///_____SUBIECTUL III 2_____
  14. #include <iostream>
  15. #include <cstring>
  16. using namespace std;
  17. int main()
  18. {
  19.     int i;
  20.     char s[101], *p, ch, aux[101], sn[101]="";
  21.     cin.getline(s, 101);
  22.     p=strtok(s, " ");
  23.     while(p)
  24.     {
  25.         strcpy(aux, p);
  26.         if(strlen(aux)>=3)
  27.         {
  28.             ch=aux[0];
  29.             for(i=0; i<strlen(aux)-1; i++)
  30.                 aux[i]=aux[i+1];
  31.             aux[strlen(aux)-1]=ch;
  32.         }
  33.         strcat(sn, aux);
  34.         strcat(sn, " ");
  35.         p=strtok(NULL, " ");
  36.     }
  37.     strcpy(s, sn);
  38.     cout<<s;
  39.  
  40.     return 0;
  41. }
  42. ///_____SUBIECTUL III 3_____
  43. #include <iostream>
  44. #include <fstream>
  45. using namespace std;
  46. ifstream fin("bac.in");
  47. int main()
  48. {
  49.     int x, f[11]={}, i;
  50.     bool ok1=0, ok2=0;
  51.     while(fin>>x)
  52.         f[x]++;
  53.     for(i=1; i<=11; i++)
  54.     {
  55.         if(ok1==1 && f[i]%2==1)
  56.         {
  57.             cout<<"NU";
  58.             ok2=1;
  59.             break;
  60.  
  61.         }
  62.         if(f[i]%2)
  63.             ok1=1;
  64.     }
  65.     if(ok2==0)
  66.         cout<<"DA";
  67.     return 0;
  68. }
  69.  
Advertisement
Add Comment
Please, Sign In to add comment