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 |
请教大牛们,我的代码问题出在哪里,谢谢啊!#include <stdio.h> #include <string.h> int C[28][12]; char s[12]; int pre() { int i, j; for (i = 0; i < 28; i++) { C[i][0] = 1; } for (i = 0; i < 12; i++) { C[i][i] = 1; } for (i = 1; i < 28; i++) { for (j = 1; j < 12 && j <= i; j++) { C[i][j] = C[i - 1][j - 1] + C[i - 1][j]; } } } int check() { int i, l, ans, j; l = strlen(s); for (i = 0; i < l - 1; i++) { if (s[i] >= s[i + 1]) { return 0; } } ans = 0; for (i = 0; i < l; i++) { ans += C[26][i]; } for (i = 0; i < s[0] - 'a'; i++) { ans += C[25 - i][l - 1]; } for (i = 1; i < l; i++) { for (j = s[i - 1] - 'a'; j < s[i] - 'a' - 1; j++) { ans += C[25 - j][l - i - 1]; } } return ans; } int main() { int i; pre(); while (scanf("%s", s) != -1) { printf("%d\n", check()); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator