Advertisement
rotti321

BAC2021 aug-sept

Mar 7th, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. 1 d
  2.  
  3. II 1 a)
  4. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  5. x x 3 4 x 6 x 8 9 x x x x x 15
  6.  
  7. 3 4 6 8 9 15
  8.  
  9. a%b==a ,a<b
  10.  
  11. 2 b) 10 7 7, 20 5 5
  12. 2 c)
  13. #include <iostream>
  14.  
  15. using namespace std;
  16.  
  17. int main() {
  18. int n,x,y,ok;
  19. cin>>n>>x>>y;
  20. ok=0;
  21. for(int i=1;i<=n;i++){
  22. if((i%x==0 && i%y!=0) ||
  23. (i%x!=0 && i%y==0)){
  24. cout<<i<<" ";
  25. ok=1;
  26. }
  27. }
  28. if(ok==0) cout<<0;
  29. return 0;
  30. }
  31.  
  32. 2 d)
  33.  
  34. citește n,x,y
  35. (numere naturale nenule, x≤n, y≤n)
  36. ok<-0
  37. i<-1
  38. ┌cat timp i<=n execută
  39. │┌dacă (i%x=0 și i%y≠0) sau
  40. ││ (i%x≠0 și i%y=0) atunci
  41. ││ scrie i, ' '
  42. ││ ok<-1
  43. || i<-i+1
  44. │└■
  45. └■
  46. ┌dacă ok=0 atunci scrie 0
  47. └■
  48.  
  49. III
  50. 1.
  51. #include <bits/stdc++.h>
  52. using namespace std;
  53.  
  54.  
  55. int main()
  56. {
  57. int n;
  58. cin>>n;
  59. for(int i=n;i>=1;i--){
  60. cout << i*i*i; cout << " ";
  61.  
  62. }
  63. return 0;
  64. }
  65.  
  66.  
  67. 3.
  68. #include <bits/stdc++.h>
  69. using namespace std;
  70.  
  71.  
  72. int main()
  73. {
  74. int n,a[100]={},b[100]={},m,x,z,u,sol=0;
  75. cin>>n>>m;
  76. for(int i=1;i<=n;i++){
  77. cin>>x;
  78. u=x%10;
  79. z=x%100/10;
  80. if(u<z){
  81. x=u*10+z;
  82.  
  83. }
  84. else{
  85. x=z*10+u;
  86. }
  87. a[x]++;//crestem aparitia lui x in primul sir
  88. }
  89. for(int i=1;i<=m;i++){
  90. cin>>x;
  91. u=x%10;
  92. z=x%100/10;
  93. if(u<z){
  94. x=u*10+z;
  95.  
  96. }
  97. else{
  98. x=z*10+u;
  99. }
  100. b[x]++;// crestem fregventa de aparitie a lui x in al doilea sir
  101. }
  102. for(int x=0;x<=99;x++){
  103. sol=sol+b[x]*a[x];
  104. }
  105. cout<<sol;
  106. return 0;
  107. }
  108.  
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement