Guest User

Untitled

a guest
Dec 13th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int n,a[50][50],i,j,aux;
  9.  
  10. int cifre[50][50];
  11. int coloane[50];
  12. int c=0;
  13. ifstream citeste("matr.in");
  14. citeste>>n;
  15. for(i=1;i<=n;i++)
  16. for(j=1;j<=n;j++)
  17. {
  18. citeste>>a[i][j];
  19.  
  20. }
  21.  
  22. for(i=1;i<=n;i++)
  23. for(j=1;j<=n;j++)
  24. {
  25. cifre[i][j]=0;
  26. aux=a[i][j];
  27. do
  28. {
  29. cifre[i][j]++;
  30. aux/=10;
  31. }
  32. while (aux);
  33.  
  34. }
  35. for(i=1;i<=n;i++)
  36. {
  37.  
  38.  
  39. for(j=1;j<=n;j++)
  40. {
  41. cout<<cifre[i][j]<<" ";
  42. }
  43. cout<<endl;
  44. }
  45. int k;
  46.  
  47.  
  48. for(j=1;j<=n;j++)
  49. {
  50. k=1;
  51.  
  52.  
  53. for(i=1;i<=n;i++)
  54. {
  55. if(i<n)
  56. if(cifre[i][j]!=cifre[i+1][j])
  57. k=0;
  58.  
  59.  
  60. }
  61. if(k==1)
  62. {
  63. c++;
  64. coloane[c]=j;
  65. }
  66.  
  67. }
  68. cout<<c<<endl;
  69. if(c==0)
  70. cout<<"Nu sunt coloane care au fiecare numere aceleas numere de cifre.";
  71. else
  72. {
  73.  
  74.  
  75. cout<<"Coloanele cu numarul de cifre al numerelor egal sunt: ";
  76. for(i=1;i<=c;i++)
  77. cout<<coloane[i]<<" ";
  78. }
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87. return 0;
  88. }
Add Comment
Please, Sign In to add comment