Advertisement
john2323

siruri de caractere exercitii manual clasa a 10 a

Feb 15th, 2021
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.98 KB | None | 0 0
  1. 1.#include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.   char a,s[256],p[256];
  6.   int i,j,r1=0,r2=0,ok,r3=0;
  7.   cin>>a;
  8.   cin>>p;
  9.   cin.getline(s,255);
  10.   for(i=0;i<strlen(s);i++)
  11.     {if(s[i]==p[0])
  12.     {ok=1;
  13.         for(j=0;j<strlen(p);j++)
  14.         if(s[i+j]!=p[j])
  15.         ok=0;
  16.     if(ok==1)
  17.         r3++;}
  18.         if(strchr("aeiouAEIOU",s[i])!=0)
  19.     r2++;
  20.     if(s[i]==a)
  21.         r1++;}
  22.     cout<<r1<<" "<<r2<<" "<<r3;
  23.     return 0;
  24. }
  25.  
  26.  
  27. 2.#include <bits/stdc++.h>
  28. using namespace std;
  29. int main()
  30. {
  31.   char s[256],a;
  32.   int i,j;
  33.   cin>>s;
  34.   a=s[0];
  35.   for(i=0;i<strlen(s);i++)
  36.     if(s[i]==a)
  37.     strcpy(s+i,s+i+1);
  38.   cout<<s;
  39.  
  40.     return 0;
  41. }
  42.  
  43. 3.#include <bits/stdc++.h>
  44. using namespace std;
  45. int main()
  46. {
  47.  char s[256],a;
  48.  int i,c;
  49.  cin>>s;
  50.  c=strlen(s)+1/2+(strlen(s)+1)%2;
  51.  for(i=0;i<c;i++)
  52.     {strcpy(s,s+1);
  53.     strcpy(s+strlen(s)-1,s+strlen(s));
  54.     cout<<s<<"\n";}
  55.     return 0;
  56. }
  57.  
  58. 5.#include <bits/stdc++.h>
  59. using namespace std;
  60. int main()
  61. {
  62.  char s[256];
  63.  int i;
  64.  cin>>s;
  65.  for(i=0;i<strlen(s);i++)
  66.     if(s[i]>='a' && s[i]<='z')
  67.     s[i]=s[i]-'a'+'A';
  68.     else
  69.     s[i]=s[i]-'A'+'a';
  70. cout<<s;
  71.    return 0;
  72. }
  73.  
  74. 6.#include <bits/stdc++.h>
  75. using namespace std;
  76. int main()
  77. {
  78.  char s[256][256];
  79.  int n,i,max1=0,max2=0,c1,c2;
  80.  cin>>n;
  81.  for(i=1;i<=n;i++)
  82.     {cin>>s[i];
  83.     if(strlen(s[i])>max1)
  84.         {max2=max1;
  85.         c2=c1;
  86.         max1=strlen(s[i]);
  87.         c1=i;}
  88.     else
  89.         if(strlen(s[i])>max2)
  90.     {max2=strlen(s[i]);
  91.      c2=i;}}
  92. cout<<s[c1]<<s[c2];
  93.    return 0;
  94. }
  95.  
  96. 7.#include <bits/stdc++.h>
  97. using namespace std;
  98. int main()
  99. {
  100.   char s[256][256],p1[256],p2[256],aux[256];
  101.   int i,j,n,ok;
  102.   cin>>n;
  103. for(i=1;i<=n;i++)
  104.     cin>>s[i];
  105. strcpy(p1,s[1]);
  106. strcpy(p2,s[2]);
  107. if(strcmp(p1,p2)>0)
  108.     swap(p1,p2);
  109. for(i=3;i<=n;i++)
  110.     if(strcmp(p1,s[i])>=0)
  111.     {strcpy(p2,p1);
  112.     strcpy(p1,s[i]);}
  113.     else
  114.     if(strcmp(p2,s[i])>=0)
  115.      strcpy(p2,s[i]);
  116.  
  117. cout<<p1<<p2;
  118.     return 0;
  119. }
  120.  
  121. 8.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement