Всегда получал WA в uva 10008 с языком программирования C
#include<stdio.h> #include<string.h> int main() { /* input the number of the line */ int n; scanf("%d",&n); fflush(stdin); /* build an array to compute the number of times that each alphabet appears */ /* countt[0] stands for 'a' , countt[1] stands for' b' ,and so on... */ int countt[26]; int i; for(i=0;i<26;i++) { countt[i]=0; } /*build an array storing the alphabet*/ char alpha[26]; char u; int numal=0; for(u='A';numal<26;u++) { alpha[numal]=u; numal++; } /*build an array prepared to receive the input(string) */ char mmm[1000][1000]; int t,g; for(t=1;t<=n;t++) { scanf("%[^\n]",mmm[t]); fflush(stdin); } /* compute each alphabet appears in the all strings , and the number of times is documented in array"countt" */ for(t=1;t<=n;t++) { for(g=0;mmm[t][g]!='\0';g++) { if(mmm[t][g]>='a' && mmm[t][g]<='z') { countt[mmm[t][g]-'a']++; } if(mmm[t][g]>='A' && mmm[t][g]<='Z') { countt[mmm[t][g]-'A']++; } } } /* sort the array"countt" in ascending order with selection sort */ /* sort the array"alpha" according to the array"countt" */ int swap,position; int o; char swap1; for(i=0;i<=24;i++) { for(o=i+1;o<=25;o++) { position=i; if(countt[i]<countt[o]) position=o; if(position==o) { swap=countt[i]; countt[i]=countt[o]; countt[o]=swap; swap1=alpha[i]; alpha[i]=alpha[o]; alpha[o]=swap1; } } } /* if the number of time that alphabets appear in the strings is equal ,then order in dictionary form (G is front of I)*/ char swap2; for(i=0;i<=24;i++) { for(o=i+1;o<=25;o++) { if(countt[i]==countt[o]) { if(alpha[i]>alpha[o]) { swap2=alpha[i]; alpha[i]=alpha[o]; alpha[o]=swap2; } } } } /* display the result*/ for(i=0;i<26;i++) { if(countt[i]!=0) { printf("%c %d\n",alpha[i],countt[i]); } } return 0; }
Выше приведен мой код (ответ на UVa 10008).
Я всегда получал результат,неправильный ответ,но я использовал функцию отладки(https://www.udebug.com/UVa/10008)чтобы проверить мой ответ,всегда идентичный принятому выходу.
Я понятия не имею, в чем проблема.
Спасибо.
Что я уже пробовал:
Я попытался отладить этот дисплей,чтобы мой ответ был правильным ,но когда я подал заявку в UVa, я получил WA.
Richard MacCutchan
Так ты дашь нам ключ к разгадке, в чем проблема?
Patrice T
Это не вопрос, мы понятия не имеем, что такое UVa 10008