Advertisement
rotti321

Carte BAC p 94

May 10th, 2021
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. S1
  2. #include <fstream>
  3. #include <iostream>
  4. #include <cstring>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.  
  10. int ap[256]={},i,k,mx=0;
  11. char s[100];
  12. cin.getline(s,100);
  13. for(i=0;i<strlen(s);i++)
  14. {
  15. if(s[i]!=' ')
  16. {
  17. k=s[i];
  18. ap[k]++;
  19. if(ap[k]>mx)
  20. mx=ap[k];
  21.  
  22. }
  23.  
  24. }
  25. for(k=0;k<256;k++)
  26. {
  27. if(ap[k]==mx)
  28. cout<<char(k)<<" ";
  29. }
  30. cout<<mx<<endl;
  31. for(char ch='a';ch<='z';ch++){
  32. cout<<ch<<" "<<ap[ch]<<" ";
  33. }
  34. }
  35.  
  36. S3
  37. #include <fstream>
  38. #include <iostream>
  39. #include <cstring>
  40. using namespace std;
  41.  
  42. int main()
  43. {
  44. int n,m,ap1[100]={},ap2[100]={},x,i,y;
  45. cin>>n>>m;
  46. for(i=1;i<=n;i++)
  47. {
  48. cin>>x;
  49. ap1[x]++;
  50. }
  51. for(i=1;i<=m;i++)
  52. {
  53. cin>>x;
  54. ap2[x]++;
  55. }
  56. x=n+1;
  57. y=1;
  58. for(i=0;i<=99;i++)
  59. {
  60. if(ap2[i]!=0)
  61. {
  62. if(ap1[i]<ap2[i])
  63. {
  64. cout<<0;
  65. return 0;
  66. }
  67. else
  68. {
  69. if(x*ap2[i]>y*ap1[i])
  70. {
  71. x=ap1[i];
  72. y=ap2[i];
  73. }
  74. }
  75. }
  76.  
  77. }
  78.  
  79. cout<<x/y;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement