Advertisement
rotti321

Probleme struct+ matrce + char

Dec 8th, 2021
926
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.91 KB | None | 0 0
  1. ###############################################
  2. Model 2022
  3. SII ex2
  4. struct zbor{
  5.     int cod, durata;
  6.     struct data{
  7.         int ora, minut;
  8.     }aterizare;
  9. }z;
  10.  
  11. SIII ex 2
  12. #include <iostream>
  13. #include <cstring>
  14. using namespace std;
  15.  
  16. int main() {
  17.     char s[101],*p;
  18.     int k=0,ok=1;
  19.     cin.getline(s,100);
  20.     p=strtok(s," ");
  21.     while(p!=NULL){
  22.         if(p[0]>='0' && p[0]<='9'){
  23.             if(k==0){
  24.                k=strlen(p);
  25.             }
  26.             else{
  27.                 if(strlen(p)!=k){
  28.                     ok=0;
  29.                 }
  30.             }
  31.         }
  32.         p=strtok(NULL," ");
  33.     }
  34.     if(ok==0){
  35.         cout<<"NU";
  36.     }
  37.     else{
  38.         cout<<k;
  39.     }
  40.     return 0;
  41. }
  42.  
  43. ###############################################
  44. BAC2019 sept
  45. SIII ex 2
  46. #include <iostream>
  47.  
  48. using namespace std;
  49.  
  50. int main() {
  51.     int n,a[21][21],m=0,ok=1,i,j;
  52.     cin >> n ;
  53.     for(int i=1;i<=n;i++){
  54.             for(int j=1;j<=n;j++){
  55.                     cin>>a[i][j];
  56.             }
  57.     }
  58.     while((m<=n)&&(ok==1)){
  59.             m++;
  60.           for(i=1;i<=m;i++){
  61.                   for(j=1;j<=m;j++){
  62.                           if(a[1][1]!=a[i][j]){
  63.                                   ok=0;
  64.                           }
  65.                   }
  66.           }
  67.  
  68.     }
  69.     if(ok==0){
  70.            cout<<m-1<<"*";
  71.     }
  72.     else{
  73.             cout<<n;
  74.     }
  75.     return 0;
  76. }
  77.  
  78. ###############################################
  79. SI BAC2019 iunie
  80. 3b
  81. SII
  82. 3.
  83. fig.raza=1;
  84. fig.centru.x=0;
  85. fig.centru.y=0;
  86.  
  87. SIII ex2
  88.  
  89. #include <iostream>
  90.  
  91. using namespace std;
  92.  
  93. int main() {
  94.     int n,a[21][21],m,ok=1,i,j;
  95.     cin >> m>>n ;
  96.     for(int i=1;i<=m;i++){
  97.             for(int j=1;j<=n;j++){
  98.                     cin>>a[i][j];
  99.             }
  100.     }
  101.      for(int j=1; j<=n/2; j++){
  102.         for(int i=1; i<=m; i++){
  103.             if(a[i][j]!=a[i][n-j+1]){
  104.                 ok=0;
  105.             }
  106.         }
  107.      }
  108.     if(ok==0){
  109.            cout<<"NU";
  110.     }
  111.     else{
  112.             cout<<"DA";
  113.     }
  114.     return 0;
  115. }
  116. ###################################################
  117. BAC 2019 SS
  118. SII ex 2
  119.  
  120. #include <iostream>
  121.  
  122. using namespace std;
  123. struct tdata
  124. {
  125.     int zi,luna;
  126. } d;
  127. struct eveniment
  128. {
  129.     int nr;
  130.     struct tdata dev;
  131. } e;
  132.  
  133. int main()
  134. {
  135.     cin>>d.zi>>d.luna;
  136.     cin>>e.dev.zi>>e.dev.luna;
  137.     if(d.luna<e.dev.luna || (d.luna==e.dev.luna && d.zi<e.dev.zi)){
  138.         cout<<"Anterior";
  139.     }
  140.     else{
  141.         cout<<"Posterior";
  142.     }
  143.        return 0;
  144. }
  145.  
  146.  
  147. SIII ex 2
  148. #include <iostream>
  149. #include <cstring>
  150. using namespace std;
  151.  
  152. int main() {
  153.     char s[101],*p;
  154.     int n,ok=0;
  155.     cin>>n;
  156.     cin.get();
  157.     cin.getline(s,100);
  158.     //cout<<s;
  159.     p=strtok(s," ");
  160.     while(p!=NULL){
  161.         if(strlen(p)==n){
  162.             cout<<p<<endl;
  163.             ok=1;
  164.         }
  165.         p=strtok(NULL," ");
  166.     }
  167.     if(ok==0){
  168.         cout<<"NU";
  169.     }
  170.  
  171.     return 0;
  172. }
  173.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement