|
|
вернуться в форумwhy got WA, I have tested with several cases! thanks! #include <iostream> using namespace std; int main(void) { char encry[101]; int temp[101]; char dencry[101]; memset(encry, 0, 101*sizeof(char)); memset(temp, 0, 101*sizeof(int)); memset(dencry, 0, 101 * sizeof(char)); fgets(encry, 101, stdin); for (int i=0; i<strlen(encry)-1; i++) { temp[i] = encry[i] - 'a'; } if (temp[0] < 5) { temp[0] += 26; } for (int i=1; i<strlen(encry)-1; i++) { while (temp[i] < temp[i-1]) { temp[i] += 26; } } for (int i=strlen(encry)-1; i>0; i--) { temp[i] = temp[i] - temp[i-1]; dencry[i] = temp[i] + 'a'; } temp[0] -= 5; dencry[0] += temp[0] + 'a'; for (int i=0; i<strlen(encry)-1; i++) { cout << dencry[i]; } cout << endl; return 0; } Re: why got WA, I have tested with several cases! thanks! got AC, after use n instead of strlen(encry)-1, where n is the number of characters. Caused by difference of strlen between compilers I think. |
|
|