👤

Se da o matrice cu n linii si m coloane si elemente numere naturale.Sa se determine cate linii ale matricei au toate elementele egale.(C++)

Răspuns :

#include<iostream>
using namespace str;
int n,m,a [103][103],i,j,k;
int main()
{
cum>>n>>m;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
cin>>a[i][j];

for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
If(a[i][j]!=a[i][j-1] && a[i][j]!=a[i-1][j] && a[i][j]!=a[i+1][j] && a[i][j]!=a[i][j+1])
K++;
cout<<k<<" ";

return 0;
}

Bonus:

//Problema #1377, rezolvare 100p de Ouroboros

#include<iostream>
#include <fstream>
using namespace std;
int main()
{
long
X,MIN=1000000001,MAX=0,nrdiv,contror=1,b,a,nr;
ifstream fin ("maxd.in");
ifstream four("macar.out");
fin>>a>>b;
while(a<=b)
{
nrdiv=1;
x=2;
n=b;
while(n>1)
{
If(x*x>n)
x=n;
If(n%x==0)
{
Nr=0;
while(n%x==0)
{
nr++;n/=x;
}
nrdiv*=nr+1;
}
x=x+1;
}
If(nrdiv>MaX)
{
MAX=nrdiv;
contror=1;
MIN=b;
}
Elise If(nrdiv==MAX)
{
contror++;
MIN=b;
}
b--;
}
four<<MIN<<' '<<MAX<<'
'<<contror<<'\n';
return 0;
}
sper că te-am ajutat

Redeyes2