ValerianBenchea

Bac 2021

Jun 24th, 2023
1,310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. ///_____SUBIECTUL III 1_____
  2. int divPrim(int n, int &s)
  3. {
  4.     int d=2, p;
  5.     s=0;
  6.     while(n!=1)
  7.     {
  8.         //cout<<"#";
  9.         p=0;
  10.         while(n%d==0)
  11.         {
  12.             p++;
  13.             n=n/d;
  14.         }
  15.         if(p%2==1)
  16.             s+=d;
  17.         d++;
  18.     }
  19.     return s;
  20. }
  21.  
  22. ///_____SUBIECTUL III 2_____
  23. #include <iostream>
  24. #include <cstring>
  25. using namespace std;
  26. char a[21][11];
  27. int main()
  28. {
  29.     int n, k, i, cnt=0;
  30.     char s[11];
  31.     cin>>n>>k;
  32.     for(i=1; i<=n; i++)
  33.     {
  34.         cin>>s;
  35.         if(strchr("aeiou", s[strlen(s)-1])!=0)
  36.             strcpy(a[++cnt],  s);
  37.     }
  38.     if(cnt>=k)
  39.         for(i=1; i<=k; i++)
  40.             cout<<a[i]<<endl;
  41.     else
  42.         cout<<"nu exista";
  43.     return 0;
  44. }
  45.  
  46. ///_____SUBIECTUL III 3_____
  47. #include <iostream>
  48. #include <fstream>
  49. using namespace std;
  50. ifstream fin("bac.txt");
  51. int main()
  52. {
  53.     int sufix, ant, x, a=-1, b=-1;
  54.     fin>>sufix;
  55.     fin>>ant;
  56.     while(true)
  57.     {
  58.         fin>>x;
  59.         if(x%1000==sufix)
  60.         {
  61.             a=x;
  62.             break;
  63.         }
  64.     }
  65.     ant=a;
  66.     while(fin>>x)
  67.     {
  68.         if(x%1000==sufix && ant%1000==sufix)
  69.         {
  70.             a=ant;
  71.             b=x;
  72.         }
  73.         ant=x;
  74.     }
  75.     if(a==-1 || b==-1)
  76.         cout<<"nu exista";
  77.     else
  78.         cout<<a<<" "<<b;
  79.     return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment