Advertisement
rotti321

Adm UVT 2019 SIII

Oct 19th, 2021
103
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int I[100][100];
  5. int verific(int a[],int n){
  6. int k=0;
  7. for(int i=0;i<n-1;i++){
  8. if(a[i]==1 && a[i+1]==0) k++;
  9. }
  10. if(k>=2) return 2;
  11. else return k;
  12. }
  13. int corect(int n){
  14. int a=-1,b=-1,st,v[100]={};
  15. for(int i=0;i<n;i++){
  16. st=verific(I[i],n);
  17. if(st==2) return 0;
  18. if(st!=0){
  19. if(a==-1)///prima linie care contine un 0
  20. a=i;
  21. b=i;
  22. }
  23. }
  24. if(a==b && a==-1) return 0;
  25. else
  26. for(int i=a+1;i<=b-1;i++){
  27. st=verific(I[i],n);
  28. if(st==0) return 0;
  29. }
  30. return 1;
  31. }
  32.  
  33. int diametru(int n){
  34. int a=-1,b=-1,st,v[100]={};
  35. for(int i=0;i<n;i++){
  36. st=verific(I[i],n);
  37. if(st!=0){
  38. if(a==-1)///prima linie care contine un 0
  39. a=i;
  40. b=i;
  41. }
  42. }
  43. /// cout<<a<<" "<<b<<endl;
  44. return b-a+1;
  45. }
  46.  
  47. int Spalindrom(int a[],int n){ ///a[]={0,0,0,0,1,2,4,5,4,2,1,0,0}
  48. for(int i=1;i<=n/2;i++){
  49. if(a[i]!=a[n-i+1]) return 0;
  50. }
  51. return 1;
  52. }
  53. int main() {
  54. int a[]={1,1,1,1,1,0,0,0,1,1,1,1},n=10;
  55. cin>>n;
  56. for(int i=0;i<n;i++){
  57. for(int j=0;j<n;j++){
  58. cin>>I[i][j];
  59. // cout<<I[i][j]<<" ";
  60. }
  61. // cout<<endl;
  62. }
  63. cout<<corect(n);
  64. return 0;
  65. }
Advertisement
RAW Paste Data Copied
Advertisement