Advertisement
john2323

BAC 2021 TEST 1 ANTRENAMENT INFO

Feb 22nd, 2021 (edited)
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. I.
  2. 1.b
  3. 2.b
  4. 3.a
  5. 4.d
  6. 5.c
  7.  
  8. II.
  9. 1.
  10. a) -1
  11. b) 7888 , 7889 ,7999
  12. c)
  13. #include <bits/stdc++.h>
  14. using namespace std;
  15. int main()
  16. {int n,m,c;
  17.     cin>>n;
  18.     m=10;
  19.     if(n==0)
  20.         m=0;
  21.     else
  22.     {do{c=n%10;
  23.         n=n/10;
  24.          if(c<=m)
  25.           m=c;
  26.           else
  27.           m=-1;
  28.          }while(n!=0);
  29.        }
  30.      cout<<m;
  31.     return 0;
  32. }
  33.  
  34. d)
  35. citește n (număr natural)
  36. m10
  37. ┌dacă n=0 atunci
  38. │ m<-0
  39. │altfel
  40. │ c<-n%10; n<-[n/10]
  41. │ ┌dacă c<=m atunci mc
  42. │ │altfel m<- -1
  43. │ └■
  44. │ ┌cat timp n!=0
  45. | | c<-n%10; n<-[n/10]
  46. |┌dacă c<=m atunci mc
  47. |│altfel m<- -1
  48. |└■
  49. │ └■
  50. └■
  51. scrie m
  52.  
  53. 2.
  54. 149
  55. 167
  56. 347
  57.  
  58. 3.
  59. 7
  60. 2020-2021
  61.  
  62. III.
  63. 1.
  64. void divX(int n,int x)
  65. {int c,i;
  66. c=n*x;
  67. for(i=n;i>=1;i--)
  68. {cout<<c<<" ";
  69. c=c-x;}
  70. }
  71.  
  72. 2.
  73. #include <bits/stdc++.h>
  74. using namespace std;
  75. int main()
  76. {int a[101][101],i,j,n;
  77. cin>>n;
  78. for(i=1;i<=n;i++)
  79.     for(j=1;j<=n;j++)
  80.     cin>>a[i][j];
  81. for(i=1;i<=n;i++)
  82. cout<<a[i][1]<<" ";
  83. for(j=2;j<=n;j++)
  84.     cout<<a[n][j]<<" ";
  85. for(i=n-1;i>=1;i--)
  86.     cout<<a[i][n]<<" ";
  87. for(j=n-1;j>=2;j--)
  88.     cout<<a[1][j]<<" ";
  89.  
  90.     return 0;
  91. }
  92.  
  93. 3.
  94. #include <bits/stdc++.h>
  95. using namespace std;
  96. ifstream fin("bac.in");
  97. int ap[101];
  98. int main()
  99. {int x,ok=0,cate=0,i;
  100. while(fin>>x)
  101. {if(log10(x)+1==2)
  102. if(ap[x]==0)
  103.     {cate++;
  104.     ap[x]=1;}}
  105. if(cate>79)
  106. cout<<"nu exista";
  107. else
  108.     for(i=99;i>=10;i--)
  109.     {if(ap[i]==0 && i%11!=0)
  110.     {cout<<i<<" ";
  111.     ok++;}
  112.     if(ok==2)
  113.         break;}
  114.     return 0;
  115. }
  116.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement