740 - Baudot Data Communication Code

All about problems in Volume 7. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
SoLtRiX
New poster
Posts: 10
Joined: Tue Dec 03, 2002 1:17 am
Location: Portugal
Contact:

740 - Baudot Data Communication Code

Post by SoLtRiX »

Cam someone send me some crucial input cases? I

turuthok
Experienced poster
Posts: 193
Joined: Thu Sep 19, 2002 6:39 am
Location: Indonesia
Contact:

Post by turuthok »

Code: Select all

        switch (ind){ 
                case 27: shift=(shift)?0:1; 
                break; 
                case 31: shift=(shift)?0:1; 
                break; 
Why do you have to flip-flop like that ... I think what you should do is change those case statements to something like this:

Code: Select all

case 27: shift = 0; break;
case 31: shift = 1; break;
Hopefully you'll get AC-ed that way ...

In addition, don't forget to always initialize each message with shift = 0.

-turuthok-
The fear of the LORD is the beginning of knowledge (Proverbs 1:7).

SoLtRiX
New poster
Posts: 10
Joined: Tue Dec 03, 2002 1:17 am
Location: Portugal
Contact:

Post by SoLtRiX »

Thanks, but i'm still getting WA. I have already submited that way and now i've submited again, but i'm still getting WA.

route
New poster
Posts: 39
Joined: Sat Dec 21, 2002 1:25 am

740 SHIFT characters.

Post by route »

1. Space is referred to the SHIFT Characters.
However, does the sequence remain the same each time?

[ SPACE --- > SHIFT DOWN --- > SHIFT UP] ?

2. "It should be initiated as "DOWN" at first."
How about if there is a shift down afterwards ?

e.g. 1011010110[shift down characters here]1011010110
|________| |________|
| |
(DOWN) (DOWN)

Is it right ?

turuthok
Experienced poster
Posts: 193
Joined: Thu Sep 19, 2002 6:39 am
Location: Indonesia
Contact:

Post by turuthok »

1. Space (' ') is not a shift-character. In the input they will simply skip the character for 11011 and 11111, those are the codes for shifting down or up. Problem description stated that a shift condition will stay that way until you get another shift-code that says otherwise.

2. Whenever you find a shift-code, just blindly apply the suggested shift-condition. I got AC-ed that way.

-turuthok-
The fear of the LORD is the beginning of knowledge (Proverbs 1:7).

VitorRodrigues
New poster
Posts: 9
Joined: Wed Apr 16, 2003 6:50 pm
Location: Braga, Portugal
Contact:

Post by VitorRodrigues »

hello.

i've been reading all the posts again and again and i still not know why my code gets WA.

can someone try to find some bug in my code? thanks

code:
[c]
#include <math.h>

char mensagem[80];
int sim;

char b1[32],b2[32];
int shift;

void inicializa()
{
int i;
for (i=0;i<80;i++)
{
mensagem=0;
}
}


void mostra_mensagem()
{
int i,j;
shift=0;
for (j=0;j<80&& mensagem[j];j+=5)
{
int b,ind=0,a;
for (a=j+4,b=0;a>=j;a--,b++)
{
ind=ind+(mensagem[a]-'0')*((int) pow(2,b));
}
switch (ind){
case 27: shift=0;break;
case 31: shift=1;break;
default:printf("%c",(!shift)?b1[ind]:b2[ind]);
}
}
}

int main()
{
int i;
sim=0;
scanf("%[^\n]",b1);
getchar();
scanf("%[^\n]",b2);
getchar();
while (scanf("%[^\n]",mensagem)>0)
{
shift=0;
getchar();
if (sim) printf("\n");
else sim=1;
mostra_mensagem();
inicializa();
}
}
[/c]

thanks for any help.

Vitor

justforfun
New poster
Posts: 5
Joined: Sun Feb 23, 2003 7:33 pm

help me~

Post by justforfun »

Is there any special input for this problem?
I've tested many input data and got correct answer in my computer..
but still got a WA!
Can anyone take a look at my code??
thanks a lot~~
[c]
#include<stdio.h>
char table[2][33],str[200],*p;
int i,code[100],count;
void encode(void)
{
i=0;
while (code)
{
if (code==31)
{
while (code[++i]!=27 && code)
putchar(table[1][code]);
if (!code)
break;
i++;
}
putchar(table[0][code]);
i++;
}
putchar('\n');
}
void deal(void)
{
for (i=0;i<200;i++)
code=0;
count=-1;
p = & str;
while (*p)
{
code[++count]=16*(*p-48)+8*(*(++p)-48)+4*(*(++p)-48)+2*(*(++p)-48)+(*(++p)-48);
p++;
}
encode();
}

int main(void)
{
gets(table[0]);
gets(table[1]);
while ((gets(str))!=NULL)
deal();
return 0;
}
[/c]

akhter900
New poster
Posts: 7
Joined: Fri Mar 19, 2004 3:27 pm

740_WA_HLP_PLS_MY..CODE

Post by akhter900 »

Any critical inputs? I cant find the problem.

Are the first two lines for only first time input ?

HELP ME................ :cry:

==============================

#include<stdio.h>
#include<math.h>

int main()
{
char d_sft[32], u_sft[32];
char code[100];
long i, j, k, flag, a, val, p;

gets(d_sft);
gets(u_sft);

while(gets(code))
{
i = 0; k = 5; flag = 0;
while(code != '\0')
{
val = 0;
for(p = 4; i < k; i++, p--)
{
a = pow(2, p);
a = a*(code-48);
val += a;
}
k += 5;
if(flag == 0)
{
if(val != 4 && val == 31)
flag = 1;
else printf("%c", d_sft[val]);
}
else if(flag == 1)
{
if(val != 4 && (val == 27))
flag = 0;
else printf("%c", u_sft[val]);
}
}
printf("\n");
}
return 0;
}

============================
AkHtEr

Post Reply

Return to “Volume 7 (700-799)”