|
|
back to boardI don't know why i get WA! Please help me! Here is my source: #include <stdio.h> int k; int capital(char c); // if capital then return 1 if notcapital return 0 // if not letter return 2; int mystrlen(char s[]); int main(void) { int i, j; int mistake = 0; char str[10000]; gets(str); for(j = 0; j < mystrlen(str)-1; j++) if(str[j] > 64 && str[j] < 123) break; if(capital(str[j]) == 0) mistake++; i = j; for(; i < mystrlen(str) - 1; i++) { if(str[i] == '.' || str[i] == '!' || str[i] == '?') { for(j = i; j < mystrlen(str)-1; j++) if(str[j] > 64 && str [j] < 123) break; if(capital(str[j]) == 0) mistake++; i = j; } } for(i = 0; i < mystrlen(str) - 1; i++) { if(capital(str[i-1]) == 2 && (str[i] > 64) && (str[i] < 123)) { i++; for(j = i; capital(str[j]) != 2; j++) { if(capital(str[j]) == 1) mistake++; } i = j; } } printf("%d", mistake); return 0; } int capital(char c) { if(c >= 65 && c <= 90) return 1; else if(c >= 97 && c <= 122) return 0; else return 2; } int mystrlen(char s[]) { for(k = 0; s[k]; k++); return k; } |
|
|