Terchea Posted November 25, 2014 Report Posted November 25, 2014 salut, ma poate ajuta cineva va rog frumos cu problema asta? Spirala Quote
Active Members MrGrj Posted November 25, 2014 Active Members Report Posted November 25, 2014 Parcurgi matricea in spirala, apoi pui elementele intr-un alt vector. Dupa ce ai pus elementele in vector verifici daca ele sunt in progresie sau nu. Quote
MARIUSCS Posted November 25, 2014 Report Posted November 25, 2014 Salut, unde e codul tau? Vrei ajutor sau vrei sa iti rezolve cineva problema??? Quote
Terchea Posted November 25, 2014 Author Report Posted November 25, 2014 #include<fstream>using namespace std;ifstream f("spirala.in");ofstream g("spirala.out");int a[101][101],n,m,x[10201],nrt;void cit(int a[101][101],int &n, int&m){f>>n>>m;for(i=1;i<=n;i++)for(j=1;j<=m;j++)f>>a[j];}void fv(int n, int m){if(n<m)nrt=n/2;else nrt=m/2;}int rez(int a[][],int n, int m){int i ,j, r=a[1][2]-a[1][1],t,Ok=1;for(t=1;t>=n-t+1&&Ok;t++){for(j=t;j<=m-t+1;j++)if(a[t][j+1]-a[t][j]!=r)Ok=0;for(i=t;i<=n-t+1;i++)if(a[i+1][t]-a[t]!=r)Ok=0;for(j=m-t+1;j>=t;j--)if(a[n-t+1][j+1]-a[n-t+1][j]!=r)Ok=0;for(i=n-t+1;i>=t;i--)if(a[i+1][m-t+1]-a[m-t+1]!=r)Ok=0;}if(Ok)return a[nrt][n-t+1];else return Nu;}int main(){cit(a[][],n,m);fv(n,m);rez(a[][],n,m);return 0;} Quote