Advertisement
rotti321

Test 11 [2021]

May 24th, 2021
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. Test 11 2021
  2.  
  3. ***********************************
  4.  
  5. I
  6. 1 c
  7. 2 d
  8. 3 a
  9. 4 c
  10. 5 d
  11.  
  12. ************************************
  13.  
  14. II
  15. 1 a ****
  16. 1 b 1,157,158
  17.  
  18. 2. f(2)=2
  19. f(21)=10
  20. f(21)=21-f(19)=21-11=10
  21. f(19)=19-f(17)=11
  22. f(17)=17-9=8
  23. f(15)=15-f(13)=15-6=9
  24. f(13)=13-f(11)=13-7=6
  25. f(11)=11-f(9)=7
  26. f(9)=9-f(7)=9-5=4
  27. f(7)=7-f(5)=7-2=5
  28. f(5)=5-f(3)=2
  29. f(3)=3
  30.  
  31. 3.
  32. 2021
  33. b!a!c!
  34.  
  35. *********************************
  36.  
  37. III
  38. 1.
  39. #include <iostream>
  40. using namespace std;
  41.  
  42. void imog(int x, int y, int &rez) {
  43. int ogl_x = 0, ogl_y = 0, c = 0, p = 1;
  44.  
  45. while(x != 0) {
  46. c = x % 10;
  47. if(c % 2 == 1) {
  48. ogl_x = ogl_x * 10 + c;
  49. }
  50. x = x / 10;
  51. }
  52.  
  53. cout << ogl_x << endl;
  54.  
  55. while(y != 0) {
  56. c = y % 10;
  57. if(c % 2 == 1) {
  58. ogl_y = c * p + ogl_y;
  59. p = p * 10;
  60. }
  61. y = y / 10;
  62. }
  63.  
  64. cout << ogl_y << endl;
  65.  
  66. /** if(ogl_x == ogl_y) rez = 1;
  67. else rez = 0; **/
  68.  
  69. rez = (ogl_x == ogl_y);
  70.  
  71. }
  72.  
  73. int main() {
  74. int x = 12345, y = 5432, rez;
  75. imog(x, y, rez);
  76. cout << rez;
  77. }
  78.  
  79.  
  80. 2.
  81.  
  82. #include <iostream>
  83. using namespace std;
  84.  
  85.  
  86. int main() {
  87. int a[21][21]={},k,aux,n;
  88. cin >> n >> k;
  89. for(int i=1;i<=n;i++){
  90. for(int j=1;j<=n;j++){
  91. cin >> a[i][j];
  92. }
  93. }
  94.  
  95. for(int i=1;i<=k-1;i++){
  96. aux=a[k][i];
  97. a[k][i]=a[i][k];
  98. a[i][k]=aux;
  99. }
  100.  
  101. for(int i=1;i<=n;i++){
  102. for(int j=1;j<=n;j++){
  103. cout << a[i][j]<<" ";
  104. }
  105. cout<<endl;
  106. }
  107. }
  108.  
  109. 3.
  110.  
  111. #include <iostream>
  112. using namespace std;
  113. ///Complexitatea O(log2(n)), unde n repr ultimul termen din sir (adica y=c)
  114.  
  115. int main() {
  116. int a,b,c,n;
  117. cin>>b>>c;
  118. cout<<c<<" "<<b<<" ";
  119. n=(c-b)/2;
  120. while(n>1){
  121. n--;
  122. a=b-2*n;
  123. cout<<a<<" ";
  124. c=b;
  125. b=a;
  126. }
  127. }
  128.  
  129.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement