Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Test 11 2021
- ***********************************
- I
- 1 c
- 2 d
- 3 a
- 4 c
- 5 d
- ************************************
- II
- 1 a ****
- 1 b 1,157,158
- 2. f(2)=2
- f(21)=10
- f(21)=21-f(19)=21-11=10
- f(19)=19-f(17)=11
- f(17)=17-9=8
- f(15)=15-f(13)=15-6=9
- f(13)=13-f(11)=13-7=6
- f(11)=11-f(9)=7
- f(9)=9-f(7)=9-5=4
- f(7)=7-f(5)=7-2=5
- f(5)=5-f(3)=2
- f(3)=3
- 3.
- 2021
- b!a!c!
- *********************************
- III
- 1.
- #include <iostream>
- using namespace std;
- void imog(int x, int y, int &rez) {
- int ogl_x = 0, ogl_y = 0, c = 0, p = 1;
- while(x != 0) {
- c = x % 10;
- if(c % 2 == 1) {
- ogl_x = ogl_x * 10 + c;
- }
- x = x / 10;
- }
- cout << ogl_x << endl;
- while(y != 0) {
- c = y % 10;
- if(c % 2 == 1) {
- ogl_y = c * p + ogl_y;
- p = p * 10;
- }
- y = y / 10;
- }
- cout << ogl_y << endl;
- /** if(ogl_x == ogl_y) rez = 1;
- else rez = 0; **/
- rez = (ogl_x == ogl_y);
- }
- int main() {
- int x = 12345, y = 5432, rez;
- imog(x, y, rez);
- cout << rez;
- }
- 2.
- #include <iostream>
- using namespace std;
- int main() {
- int a[21][21]={},k,aux,n;
- cin >> n >> k;
- for(int i=1;i<=n;i++){
- for(int j=1;j<=n;j++){
- cin >> a[i][j];
- }
- }
- for(int i=1;i<=k-1;i++){
- aux=a[k][i];
- a[k][i]=a[i][k];
- a[i][k]=aux;
- }
- for(int i=1;i<=n;i++){
- for(int j=1;j<=n;j++){
- cout << a[i][j]<<" ";
- }
- cout<<endl;
- }
- }
- 3.
- #include <iostream>
- using namespace std;
- ///Complexitatea O(log2(n)), unde n repr ultimul termen din sir (adica y=c)
- int main() {
- int a,b,c,n;
- cin>>b>>c;
- cout<<c<<" "<<b<<" ";
- n=(c-b)/2;
- while(n>1){
- n--;
- a=b-2*n;
- cout<<a<<" ";
- c=b;
- b=a;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement