Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:帮忙看一下,是算法错了还是怎么的In Reply To:帮忙看一下,是算法错了还是怎么的 Posted by:minidick at 2003-12-18 20:54:17 > void quick_sort(int *x, int low, int high) > { > int i, j, t; > if (low < high) { > i = low; > j = high; > t = *(x+low); > while (i<j) > { > while (i<j && *(x+j)>t) > { > j--; > } > if (i<j) > { > *(x+i) = *(x+j); > i++; > } > while (i<j && *(x+i)<=t) > { > i++; > } > if (i<j) > { > *(x+j) = *(x+i); > j--; > } > } > *(x+i) = t; > quick_sort(x,low,i-1); > quick_sort(x,i+1,high); > } > } > main() > { > int i, j, k = 1, r, c, n = 0, a[102][102], m[4] = {1, 102, -1, -102}; > int *p[10001] ; > scanf("%d%d", &r, &c); > for (i = 1; i <= c; i++) > a[0][i] = a[r+1][i] = 32766; > for (i = 1; i <= r; i++) > a[i][0] = a[i][c+1] = 32766; > for (i = 1; i <= r; i++) > for (j = 1; j <= c; j++) > scanf("%d",p[k++] = &a[i][j]); > quick_sort(p, 1, r * c); > for (i = 1; i <= r * c; i++) { > k = 0; > for (j = 0; j < 4; j++) > if (*(p[i]+m[j]) <= *p[i] && *(p[i]+m[j]) > k) > k = *(p[i]+m[j]); > if ((*p[i] = k + 1) > n) n = *p[i]; > } > printf("%d\n", n); > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator