ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1094. E-screen

ADMINS!WHY WA#1???
Posted by 123 29 May 2010 23:23
#include<stdio.h>
#include<iostream>
using namespace std;

char s[10001],str[80];
int main()
{

#ifndef ONLINE_JUDGE
   freopen("input.txt", "rt", stdin);
   freopen("output.txt", "wt", stdout);
#endif

         int j = 0;
         memset(s,'\0',sizeof(s));
        while(gets(s))
        {
                int len = strlen(s);
                int i = 0;
                while(i<len)
                {
                        if(s[i]=='>')
                        {
                                j++;
                                if(j>79)j=0;
                        }
                        else if(s[i]=='<')
                        {
                                j--;
                                if(j<=0)j=0;
                        }
                        else if(s[i]!='\n' && s[i]!='\0')
                        {
                                str[j] = s[i];
                                j++;
                        }
                        i++;
                }

                memset(s,'\0',sizeof(s));
        }
for(int i = 0;i<80;i++)
printf("%c",str[i]);

return 0;
}
Re: ADMINS!WHY WA#1???
Posted by Sandro (USU) 29 May 2010 23:36
"at the beginning the e-screen contains 80 spaces"
Re: ADMINS!WHY WA#1???
Posted by 123 29 May 2010 23:44
I add in begin
memset(str,' ',sizeof(80));

I get WA#1 to former =(
Re: ADMINS!WHY WA#1???
Posted by sokoL[TSOGU] 31 May 2010 20:05
Thank you!!!You help me!!!I got AC!!!=)