Page 2 of 16

Posted: Sun Dec 22, 2002 7:21 pm
by takumi
uhmmmm I am really confuses now..
I chance my code a little but it still WA
do it got anything goes wrong
[c]#include <stdio.h>

int main()
{
char input[1001];
int i, temp, ascii[256];

for ( i = 0; i < 1001; i++ ) { input = NULL; }

while (gets(input) != NULL) {
for ( i= 0; i <= 256; i++ ) { ascii = 0; }

for ( i = 0; i < 1001; i++ ) {
temp = input;
ascii[temp]++;
}
if ( input[0] == input[1] && input[0] != '\0' && input[1] != '\0' ) {

for ( i = 255; i > 0; i-- ) {
if ( ascii != 0 ) { printf("%d %d\n", i, ascii ); }

}
}
else {
for ( i = 1; i < 256; i++ ) {
if ( ascii != 0 ) { printf("%d %d\n", i, ascii ); }
}
}
for ( i = 0; i <= 1001; i++ ) { input = NULL; }

}
return 0;
}[/c]
thanks for repply :)

Posted: Sun Dec 22, 2002 7:39 pm
by route
a blank line after each set of output...

Posted: Mon Dec 23, 2002 6:50 pm
by takumi
there is some question I want to ask
1. if the linput like this:
<blank line><blank line>122333
what should the output like?

49 1
50 2
51 3

or

51 3
50 2
49 1

2. do the ascii value for all character has to be printed even 'blank line' and 'enter' char??

thank you very much..

Posted: Mon Dec 23, 2002 7:21 pm
by deddy one
ascii for enter?? I don't think you should print that. But for space you should print the value , sort them like the output description tell

Please help me !!!

Posted: Tue Mar 25, 2003 3:41 am
by amd-RS
Hi all,

I don't understand why I get WA on my code:

[c]
#include <stdio.h>

void main ()
{
int i, j, c = 0, vetor[256], vetor1[256], temp1;
char str[1000], temp;

while (gets(str) != NULL)
{
for (i = 0; i < 256; i++)
{
vetor = vetor1 = 0;
}
temp1 = 0;
str[1000]='\0';

for (i = 1; str != '\0'; i++)
{
for (j = 1; str[j] != '\0'; j++)
{
if (str[j - 1] < str)
{
temp = str[j - 1];
str[j - 1] = str;
str = temp;
}
}
}
for (i = 0;str != '\0' ; i++)
{
while (str == str[i + 1])
{
c++;
i++;
}
vetor[temp1] = c + 1;
vetor1[temp1] = str;
temp1++;
c = 0;
}
for (i = 0; i < temp1; i++)
for (j = i + 1; j < temp1; j++)
{
if (vetor > vetor[j])
{
temp = vetor[i];
vetor[i] = vetor[j];
vetor[j] = temp;
temp = vetor1[i];
vetor1[i] = vetor1[j];
vetor1[j] = temp;
}
else if (vetor[i] == vetor[j]
&& vetor1[i] < vetor1[j])
{
temp = vetor1[i];
vetor1[i] = vetor1[j];
vetor1[j] = temp;
}
}


for (i = 0; i < temp1; i++)
printf ("%d %d\n", vetor1[i], vetor[i]);
if(str[0]!='\n')
printf("\n");
}
}
[/c]

Please, help me, I'm going nut. I spent over a week at this problem :(

10062

Posted: Mon Mar 31, 2003 7:46 am
by amd-RS
Hi,

First of all, I think you should do ascii check conditon ...

Good luck , Aur

10062

Posted: Thu Apr 03, 2003 6:14 am
by WillieLi
this code got accepted but the online judge said it has presentation error..@@
could anyone examine the code below and tell me why??...
thanx a lot in advance...:D

[cpp]
#include <stdio.h>
#include <string.h>

void main()
{
int b[256],i;
char str[10000];
for(i = 0;i <= 130; i++)
{
b = 0;
}
while(gets(str))
{
int final = 0,j;
for(i = 0; i < strlen(str); i++)
{
if(str >= 32 && str <= 127)
{
b[str]++;
if(b[str] > final)
final = b[str];
else
final = final;
}
}
for(i = 1;i <= final; i++)
{
for(j = 130; j >= 0; j--)
{
if(b[j] == i)
{
printf("%d %d\n",j,i);
b[j] = 0;
}
}
}
printf("\n");
}
}
[/cpp]

Posted: Fri Apr 04, 2003 8:51 am
by cytse
there should be no blank line after the last set of output

Posted: Sat Apr 05, 2003 6:57 am
by Professor_Of_Love
I am very very disappointed with this problem... I am getting WA. But I have solved similar problem like #10008. I can't find any mistake here. Can anyone help me?? Thanks in advance!

[c]#include<stdio.h>
#include<string.h>
#define N 10000
#define M 160

struct {
char ch;
int c;
}chrs[M];

unsigned char str[N],countStruct,i,j;

int isValid(char ch)
{
if(ch>=32&&ch<=127)
return 1;
else
return 0;
}

void swap(int *i, int *j)
{
*i = *i + *j - (*j=*i);
return;
}

void swapC(char *i, char *j)
{
*i = *i + *j - (*j=*i);
return;
}

void init()
{
int i;
for(i=0;i<M;i++)
chrs.ch=0,chrs.c=0;
return;
}

void main(void)
{
while(gets(str))
{
init();
countStruct = 0;
for(i=0;i<strlen(str);i++)
{
if(isValid(str))
{
for(j=0;j<countStruct;j++)
if(chrs[j].ch==str)
{
chrs[j].c++;
break;
}
if(j>=countStruct)
countStruct++,chrs[j].c=1,chrs[j].ch=str;
}
}
for(i=0;i<countStruct-1;i++)
for(j=i+1;j<countStruct;j++)
if(chrs.c>chrs[j].c)
{
swapC(&chrs.ch,&chrs[j].ch);
swap(&chrs.c,&chrs[j].c);
}
for(i=0;i<countStruct-1;i++)
for(j=i+1;j<countStruct;j++)
if((chrs.c==chrs[j].c)&&(chrs.ch<chrs[j].ch))
swapC(&chrs[i].ch,&chrs[j].ch);
for(j=0;j<countStruct;j++)
printf("%d %d\n",chrs[j].ch,chrs[j].c);
printf("\n");
}
}[/c]

Posted: Sat Apr 05, 2003 10:42 am
by anupam
in online judge forget about presentation error...
it doesn't indicate author's lagging....

---
anupam :oops: :oops: :oops:

Posted: Sat Apr 05, 2003 7:50 pm
by Professor_Of_Love
But, what about my WA??

10062 WA

Posted: Fri May 02, 2003 3:16 pm
by JiaYun
As comments, I hava tried several ways. But it's still WA.... :cry:

[cpp]
deleted
[/cpp]

Wa Wa Wa

Posted: Fri May 02, 2003 5:26 pm
by JiaYun
Still WA....:cry:

[cpp]deleted
[/cpp]

Posted: Sun May 04, 2003 10:41 am
by LittleJohn
Maybe you should try with a bigger input range than the problem's description, I guess.

Posted: Tue May 06, 2003 5:00 pm
by JiaYun
You mean the maximum length of each line? I modified it to 10001, but still WA.... :cry: