Advertisement
john2323

Examen de bacalaureat 2020 - Variante propuse - Testul 3 (Matematica Informatica)

Dec 29th, 2020 (edited)
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. I.
  2. 1.d
  3. 2.b
  4. 3.c
  5. 4.a
  6. 5.b
  7. II.
  8. 1.
  9. a)
  10. 1 27545
  11. b)
  12. 78 75
  13. c)
  14. #include<iostream>
  15. using namespace std;
  16. int main()
  17. {int n,c1,c2,s;
  18. cin>>n;
  19. c1=n%10;
  20. n/=10;
  21. c2=n%10;
  22. if(c1==c2)
  23.     s=0;
  24. else
  25.     if(c1>c2)
  26.      s=1;
  27.      else
  28.      s=-1;
  29.  
  30. do
  31. {c1=n%10;
  32. n/=10;
  33. c2=n%10;
  34. }while((c1-c2)*s<=0);
  35. cout<<s<<" "<<n;
  36. }
  37.  
  38. d)
  39. #include<iostream>
  40. using namespace std;
  41. int main()
  42. {int n,c1,c2,s;
  43. cin>>n;
  44. c1=n%10;
  45. n/=10;
  46. c2=n%10;
  47. if(c1==c2)
  48.     s=0;
  49. else
  50.     if(c1>c2)
  51.      s=1;
  52.      else
  53.      s=-1;
  54. c1=n%10;
  55. n/=10;
  56. c2=n%10;
  57. while((c1-c2)*s<0)
  58. {c1=n%10;
  59. n/=10;
  60. c2=n%10;
  61. }
  62. cout<<s<<" "<<n;
  63. }
  64.  
  65. 2.
  66. struct cerc
  67. {int x,y,raza;}fig;
  68. 3.
  69. #include <bits/stdc++.h>
  70. using namespace std;
  71.  
  72. int main()
  73. { char s[101],p;
  74. cin>>s;
  75. for(p=0;p<=strlen(s)-1;p++)
  76.     if(p==0)
  77.     {if(s[p]=='A' && s[p+1]=='I')
  78.     strcpy(s+p,s+p+1);}
  79.     else
  80.     if(s[p]=='A' && (s[p-1]=='I' || s[p+1]=='I'))
  81.     strcpy(s+p,s+p+1);
  82. cout<<s;
  83.     return 0;
  84. }
  85.  
  86.  
  87. III.
  88. 1.
  89. int factori(int x,int y)
  90. {int d=2,p=0,c=0,ok1,ok2;
  91. while(x!=1)
  92. {while(x%d==0)
  93. {x=x/d;
  94. ok1=1;}
  95. while(y%d==0)
  96. {y=y/d;
  97. ok2=1;}
  98. if(ok1==1 && ok2==1)
  99.         {c++;
  100.    ok1=0;
  101.    ok2=0;}
  102.    else
  103.     {ok1=0;
  104.     ok2=0;}
  105. d++;
  106. }
  107.  return c;
  108. }
  109. 2.
  110. #include <iostream>
  111. using namespace std;
  112. int a[21][21];
  113. int main()
  114. {int n,i,j;
  115. cin>>n;
  116. for(i=1;i<=n;i++)
  117. {a[i][1]=n-i;
  118. a[n][n-i+1]=n-i;
  119.     for(j=2;j<=n-i;j++)
  120.     {a[i][j]=a[i][j-1]-1;
  121.     a[n-j+1][n-i+1]=a[i][j];}}
  122.     for(i=1;i<=n;i++)
  123.         {for(j=1;j<=n;j++)
  124.         cout<<a[i][j]<<" ";
  125.     cout<<"\n";}
  126.     return 0;
  127. }
  128.  
  129.    3.
  130. #include <iostream>
  131. #include <fstream>
  132. using namespace std;
  133. ifstream fin("bac.in");
  134. int main()
  135. {
  136.     int x,x1,x2,p=0,ok=0;
  137.     while(fin>>x)
  138.     {p++;
  139.     if(ok==0 && x<0)
  140.     {x1=p;
  141.     ok=1;}
  142.     if(x<0)
  143.     x2=p;
  144.     }
  145. cout<<max(p-x1+1,x2);
  146.     return 0;
  147. }
  148.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement