391 - Mark-up
Moderator: Board moderators
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
391 - Mark-up .... help !
Could anyone give me any special cases for this problem ?
I use finite state machine to solve this question, but stil got WA ....
Is any other trick than I have to print "34" where I found "\s1.234" ??
And what should I print where I found "\S1.123" ??
I use finite state machine to solve this question, but stil got WA ....
Is any other trick than I have to print "34" where I found "\s1.234" ??
And what should I print where I found "\S1.123" ??
-
- New poster
- Posts: 1
- Joined: Tue Aug 13, 2002 9:48 pm
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
Code: Select all
Is any other trick than I have to print "34" where I found "\s1.234" ??
And what should I print where I found "\S1.123" ??
some tricky case i know is :
Code: Select all
input:
\s3.4a\sb\s.5c\s100.d\s12e
\**\\***\\*\*\*
output:
abcde
*\**\*
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
I don't know what's wrong with this code ....
I got the same result as you, arc16, but still WA
could anyone help me ?
Dominik
------------------------------
I got the same result as you, arc16, but still WA
could anyone help me ?
Dominik
------------------------------
Code: Select all
I cut off the code, because it was a solution after some modifications ;-)
Last edited by Dominik Michniewski on Mon Sep 23, 2002 10:31 am, edited 1 time in total.
haven't take a deep look at your program, but my guess is thatDominik Michniewski wrote:I don't know what's wrong with this code ....
I got the same result as you, arc16, but still WA
could anyone help me ?
your program cannot process either a sequencing '\' and '*' characters correctly. Check out the following test case:
Code: Select all
input:
\**\\***\\*\*\*
\*
\\
\*
\\ \a\b\c\d\e\f\g\\h\\\*
your output:
*\**\*
\\
\ \a\c\d\e\f\g\h\
correct output:
*\**\*
\\
\ acdefg\h\
good luck

-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
-
- Experienced poster
- Posts: 192
- Joined: Sat Nov 30, 2002 5:14 am
Consider This sample:
Did You see the difference?
when the input is "\\" You should print the "\" when the toggle processing of mark-ups on;
otherwise you should print exactly as they appear in the input.
Note:

Code: Select all
Sample Input
LSKD AODP.
\\ akdf \\
\* asifj \\ \\\
\\\\
\\ askf asf\afa\
\* \\ \bisjaf
Output:
LSKD AODP.
\ akdf \
asifj \\ \\\
\\\\
\\ askf asf\afa\
\ isjaf
when the input is "\\" You should print the "\" when the toggle processing of mark-ups on;
otherwise you should print exactly as they appear in the input.
Note:
RS.At the start, processing of mark-ups should be on.

Thanks for your reply. My program matches with all the input and output of yours. Will anybody kindly see my program and tell me where i am wrong. Here is my code:
Code: Select all
#include <stdio.h>
#include <string.h>
main()
{
char a[10000];
int flag1,flag2,flag3,flag4,i,j,l1;
while(1)
{
if(gets(a)==NULL) break;
l1=strlen(a);
flag1=flag2=flag3=0;
for(i=0;i<l1;i++)
{
if(a[i]=='\\')
{
if(a[i+1]=='b'&&flag4!=0) {i++;flag1=1;}
else if(a[i+1]=='s'&&flag4!=0)
{
flag2=1;
for(j=i+2;;j++)
if(!((a[j]>='0' && a[j]<='9')||a[j]=='.')) break; ;
i=j-1;
}
else if(a[i+1]=='*')
{
i++;
if(flag4==0) flag4=1;
else flag4=0;
}
else if(a[i+1]=='\\'&&flag4!=0)
{
i++;
printf("\\");
}
else if (flag4==0) printf("%c",a[i]);
}
else printf("%c",a[i]);
}
printf("\n");
}
return 0;
}
Thanks in advance.
if there be space charecter after the mark up off,
will i print it or not..
i found the problem harder then i guessed before..
-- if the mark up command is off then all the charecters get printed or not..
if yes then the code of yahoo has no mistakes i think...
--if no please reply why?
--anupam
"Everything should be made simple, but not always simpler"
I've no idea why this does not work
Any suggestion?

Code: Select all
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define ON 1
#define OFF 0
int main(void) {
char vrsta[100000];
char *p;
int process = ON, pika, prva = 1;
while (!feof(stdin)) {
gets(vrsta);
p = vrsta;
if (!prva) putchar('\n'); else prva = 0;
while (*p != '\0') {
if (*p == '\\') {
if (*(p+1) == 'b' && process) {
p+=2;
} else if (*(p+1) == 'i' && process) {
p+=2;
} else if (*(p+1) == '*') {
process = (process==ON)?OFF:ON;
p+=2;
} else if (*(p+1) == 's' && process) {
p+=2;
pika = 0;
while (isdigit(*p) || (*p == '.' && !pika)) {
if (*p == '.') pika++;
p++;
}
} else {
if (!process) {
putchar(*p);
p++;
} else {
if (*(p+1) != '\0') {
p++;
putchar(*p);
p++;
} else {
p++;
putchar('\\');
}
}
}
} else {
putchar(*p);
p++;
}
}
}
return(0);
}
391 - Mark-up
remove after accept!
Last edited by Navid666 on Wed Jul 12, 2006 9:21 pm, edited 1 time in total.
=;GOOD LUCK=;
NAvidOP
NAvidOP
May this helps you !
Hi Navid,
Test this input to your program, it should generate the output
below which my Accepted Code generated.
Hope you figure out your problem with this test cases.
Input :
\s3.4a\sb\s.5c\s100.d\s12e
\*\b no translation should occur *\\ \b*\s3.*\*
/i/b/s\bb\ii\ss
\**\\***\\*\*\*
\*
\\
\*
\\ \n\o\ \p\r\ob\l\e\m\*s\*
\* close literal text by end-of-file\
Desired Output :
abcde
\b no translation should occur *\\ \b*\s3.*
/i/b/sbis
*\**\*
\\
\ no problems
close literal text by end-of-file\
Test this input to your program, it should generate the output
below which my Accepted Code generated.
Hope you figure out your problem with this test cases.

Input :
\s3.4a\sb\s.5c\s100.d\s12e
\*\b no translation should occur *\\ \b*\s3.*\*
/i/b/s\bb\ii\ss
\**\\***\\*\*\*
\*
\\
\*
\\ \n\o\ \p\r\ob\l\e\m\*s\*
\* close literal text by end-of-file\
Desired Output :
abcde
\b no translation should occur *\\ \b*\s3.*
/i/b/sbis
*\**\*
\\
\ no problems
close literal text by end-of-file\