Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- int n,a[50][50],i,j,aux;
- int cifre[50][50];
- int coloane[50];
- int c=0;
- ifstream citeste("matr.in");
- citeste>>n;
- for(i=1;i<=n;i++)
- for(j=1;j<=n;j++)
- {
- citeste>>a[i][j];
- }
- for(i=1;i<=n;i++)
- for(j=1;j<=n;j++)
- {
- cifre[i][j]=0;
- aux=a[i][j];
- do
- {
- cifre[i][j]++;
- aux/=10;
- }
- while (aux);
- }
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=n;j++)
- {
- cout<<cifre[i][j]<<" ";
- }
- cout<<endl;
- }
- int k;
- for(j=1;j<=n;j++)
- {
- k=1;
- for(i=1;i<=n;i++)
- {
- if(i<n)
- if(cifre[i][j]!=cifre[i+1][j])
- k=0;
- }
- if(k==1)
- {
- c++;
- coloane[c]=j;
- }
- }
- cout<<c<<endl;
- if(c==0)
- cout<<"Nu sunt coloane care au fiecare numere aceleas numere de cifre.";
- else
- {
- cout<<"Coloanele cu numarul de cifre al numerelor egal sunt: ";
- for(i=1;i<=c;i++)
- cout<<coloane[i]<<" ";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment