Advertisement
Guest User

Model BAC 2018 Info

a guest
Nov 22nd, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.86 KB | None | 0 0
  1. ///SII 4.
  2.  
  3. #include <iostream>
  4. #include <cstring>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     char s[20],x[20];
  10.     cin.getline(s,20);
  11.     if(strlen(s)%2==0){
  12.         strcpy(x,s);
  13.     }
  14.     else{
  15.         strcpy(x,s);
  16.        /// cout<<x+strlen(x)/2<<endl;
  17.        /// cout<<x+strlen(x)/2+1<<endl;
  18.         strcpy(x+strlen(x)/2,x+strlen(x)/2+1);
  19.     }
  20.     cout<<x;
  21.     return 0;
  22. }
  23.  
  24. SII 5.
  25.  
  26. #include <iostream>
  27. #include <cmath>
  28. using namespace std;
  29.  
  30. int main()
  31. {
  32.     int n,a[51][51]={};
  33.     cin>>n;
  34.     for(int i=1;i<=n;i++){
  35.         for(int j=1;j<=n;j++){
  36.             if(i+j==n || i+j==n+1 || i+j==n+2) a[i][j]=1; ///pseudodiagonale sec
  37. ///            if(i==j || i==j+1 || i==j-1) a[i][j]=1; ///pseudodiagonale princ
  38.             else a[i][j]=2;
  39.             cout<<a[i][j]<<" ";
  40.            /// cout<<i<<j<<" ";
  41.         }
  42.         cout<<endl;
  43.     }
  44.     return 0;
  45. }
  46.  
  47. SIII 3.
  48. #include <iostream>
  49. #include <cmath>
  50. using namespace std;
  51.  
  52. void divizori(int n,int &x,int &y,int &z)
  53. {
  54.     x=0;    y=0;    z=0;
  55.     int i,j,k;
  56.     for(i=1;i<=n/2;i++){
  57.         for(j=i+1;j<=n/2;j++){
  58.             for(k=j+1;k<=n/2;k++){
  59.                 if(i+j+k==n && n%i==0 && n%j==0 && n%k==0){
  60.                     x=i;    y=j;    z=k;
  61.                     break;
  62.                 }
  63.             }
  64.         }
  65.     }
  66. }
  67. int main()
  68. {
  69.     int x,y,z,n;
  70.     cin>>n;
  71.     divizori(n,x,y,z);
  72.     cout<<x<<" "<<y<<" "<<z;
  73.     return 0;
  74. }
  75.  
  76. SIII 4.
  77. #include <iostream>
  78. #include <fstream>
  79. using namespace std;
  80. ifstream fin("bac.txt");
  81.  
  82. int a[100]={};
  83. int main()
  84. {
  85.     int nr,subnr;
  86.     while(fin>>nr){
  87.         ///preiau toate subnumerele lui nr
  88.         while(nr>=10){
  89.             subnr=nr%100;
  90.             a[subnr]++;
  91.             nr=nr/10;
  92.         }
  93.     }
  94.     for(int x=10;x<=99;x++){
  95.         if(a[x]==1){
  96.             cout<<x<<" ";
  97.         }
  98.     }
  99.     return 0;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement