#include #include int n; char tri[220][110]; int t[220][110]; int ncase; FILE *in; int MAX; void readin(int n) { char s[220]; int i,j; for (i=0;i<210;i++) for (j=0;j<105;j++) { tri[i][j] = '#'; t[i][j] = -1; } for (j=0; j= 0 && y >=0 && y < n && x < len(y) && tri[x][y] != '#'); } int groesse(int x, int y, int wert) { int wert1, wert2; if (x>=2*n-1 || y>=n) return 0; if (t[x][y] >=0 ) return t[x][y]; if (tri[x][y] == '#') return 0; if (tri[x+1][y] == '#') return 1; wert1 = groesse(x+2, y, wert+1); if (wert1+wert+1>MAX) wert2 = groesse(x, y+1, wert+1); else wert2 = 0; if (wert1>wert2) return t[x][y]=(wert2+1); else return t[x][y]=(wert1+1); } int groesseoben(int x, int y, int wert) { int wert1, wert2; if (x>=2*n-1 || y>=n) return 0; if (t[x][y] >=0 ) return t[x][y]; if (tri[x][y] == '#') return 0; if (tri[x-1][y+1] == '#') return 1; if (x==1) wert1=0; else wert1 = groesseoben(x-2, y+1, wert+1); if (wert1+wert+1>MAX) wert2 = groesseoben(x, y+1, wert+1); else wert2=0; if (wert1>wert2) return t[x][y]=(wert2+1); else return t[x][y]=(wert1+1); } /* int biggestup(int x, int y) { int x2=x; while (white(x2,y)) x2 += 2; if (x2==x) int biggest(int x, int y) { if (x%2 == 0) return biggestdown(x, y); else return biggestup(x, y); } */ int power( int bas, int expo) { int i; int h; h=0; for (i=0; iMAX) MAX=t; i += 2; } /* printf("\n");*/ j++; i=0; } i=1; j=0; while (jMAX) MAX=t; i += 2; } /* printf("\n");*/ j++; i=1; } printf("Triangle #%d\n", ncase); printf("The largest triangle area is %d.\n\n", MAX*MAX); fscanf(in, "%d", &n); } return 0; }