Remember that \ has a special meaning in strings!const char check[]= "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./ nn";
10082 - WERTYU
Moderator: Board moderators
10082 O.L why???
why do i get output limited exceeded
Output Limit Exceeded (OL): Your program tried to write too much information. This usually occurs if it goes into a infinite loop
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
[cpp]
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{
char array [128];
int i;
for (i = 0; i < 128; i++)
array = 0;
array [' '] = ' ';
array ['\n'] = '\n';
array['\''] = '\'';
array['1'] = '\'';
array['2'] = '1';
array['3'] = '2';
array['4'] = '3';
array['5'] = '4';
array['6'] = '5';
array['7'] = '6';
array['8'] = '7';
array['9'] = '8';
array['0'] = '9';
array['-'] = '0';
array['='] = '-';
array['W'] = 'Q';
array['E'] = 'W';
array['R'] = 'E';
array['T'] = 'R';
array['Y'] = 'T';
array['U'] = 'Y';
array['I'] = 'U';
array['O'] = 'I';
array['P'] = 'O';
array['['] = 'P';
array[']'] = '[';
array['\\'] = ']';
array['S'] = 'A';
array['D'] = 'S';
array['F'] = 'D';
array['G'] = 'F';
array['H'] = 'G';
array['J'] = 'H';
array['K'] = 'J';
array['L'] = 'K';
array[';'] = 'L';
array['\''] = ';';
array['X'] = 'Z';
array['C'] = 'X';
array['V'] = 'C';
array['B'] = 'V';
array['N'] = 'B';
array['M'] = 'N';
array[','] = 'M';
array['.'] = ',';
array['/'] = '.';
char character;
while (scanf("%c", &character))
{
if (array[character] != 0)
{
printf("%c", array[character]);
}
}
return 0;
}
[/cpp]
Output Limit Exceeded (OL): Your program tried to write too much information. This usually occurs if it goes into a infinite loop
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
[cpp]
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{
char array [128];
int i;
for (i = 0; i < 128; i++)
array = 0;
array [' '] = ' ';
array ['\n'] = '\n';
array['\''] = '\'';
array['1'] = '\'';
array['2'] = '1';
array['3'] = '2';
array['4'] = '3';
array['5'] = '4';
array['6'] = '5';
array['7'] = '6';
array['8'] = '7';
array['9'] = '8';
array['0'] = '9';
array['-'] = '0';
array['='] = '-';
array['W'] = 'Q';
array['E'] = 'W';
array['R'] = 'E';
array['T'] = 'R';
array['Y'] = 'T';
array['U'] = 'Y';
array['I'] = 'U';
array['O'] = 'I';
array['P'] = 'O';
array['['] = 'P';
array[']'] = '[';
array['\\'] = ']';
array['S'] = 'A';
array['D'] = 'S';
array['F'] = 'D';
array['G'] = 'F';
array['H'] = 'G';
array['J'] = 'H';
array['K'] = 'J';
array['L'] = 'K';
array[';'] = 'L';
array['\''] = ';';
array['X'] = 'Z';
array['C'] = 'X';
array['V'] = 'C';
array['B'] = 'V';
array['N'] = 'B';
array['M'] = 'N';
array[','] = 'M';
array['.'] = ',';
array['/'] = '.';
char character;
while (scanf("%c", &character))
{
if (array[character] != 0)
{
printf("%c", array[character]);
}
}
return 0;
}
[/cpp]
Last edited by powerboy on Tue Jul 01, 2003 10:22 pm, edited 2 times in total.
10082
Here is my code, thanks in advance.
[cpp]#include <iostream.h>
int const Max=47;
char S[Max]={"`1234567890-=QWERTYUIOP[]ASDFGHJKL;'ZXCVBNM,./"};
int search(char ch)
{
int i;
for(i=0;i<Max;i++)
if(ch==S) break;
return i;
}
void main()
{
char ch;
while(ch=cin.get())
{
if(ch==EOF) break;
//printf("%c",S[search(ch)-1]);
cout<<S[search(ch)-1]<<flush;
}
//cout<<endl;
}
[/cpp]
if(ch==EOF) break
When add this line got WA.
when remove this line got TLE.
[cpp]#include <iostream.h>
int const Max=47;
char S[Max]={"`1234567890-=QWERTYUIOP[]ASDFGHJKL;'ZXCVBNM,./"};
int search(char ch)
{
int i;
for(i=0;i<Max;i++)
if(ch==S) break;
return i;
}
void main()
{
char ch;
while(ch=cin.get())
{
if(ch==EOF) break;
//printf("%c",S[search(ch)-1]);
cout<<S[search(ch)-1]<<flush;
}
//cout<<endl;
}
[/cpp]
if(ch==EOF) break
When add this line got WA.
when remove this line got TLE.
AC makes me feels good,
But WA makes me thinks hard.
But WA makes me thinks hard.
-
- Experienced poster
- Posts: 136
- Joined: Tue Apr 01, 2003 6:59 am
- Location: Jakarta, Indonesia
10082 WA
I don know why this simple problem getting so tough
[cpp]
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
char ch;
while(cin.get(ch))
{
int index = str.find(ch);
if(ch == '\n')
cout << '\n';
else
cout << str[index-1];
}
return 0;
}
[/cpp]
![:oops:](./images/smilies/icon_redface.gif)
[cpp]
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
char ch;
while(cin.get(ch))
{
int index = str.find(ch);
if(ch == '\n')
cout << '\n';
else
cout << str[index-1];
}
return 0;
}
[/cpp]
My own quote:
We are here as Adam and Eve were here!
We are here as Adam and Eve were here!
10082 WA ~~~help
Code: Select all
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
int main()
{
char c;
int num=0;
string s[4];
s[0] = "`1234567890-=";
s[1] = "QWERTYUIOP[]\\";
s[2] = "ASDFGHJKL;'";
s[3] = "ZXCVBNM,./";
while(cin.get(c))
{
if (c == EOF) break;
if (c != ' ')
{
for (int i=0; i<4; i++)
{
int k = s[i].find(c);
if (k != string::npos){
cout << s[i][k-1] << flush;
break;
}
}
}else{
cout << c << flush;
}
}
return 0;
}
I am not sure if there is any boundary condition I miss. My file name is
"main.cpp", and I use upload file to submit my code. Could anyone tell me what is wrong with my code? I will appreciate for your help!!
You are not handling newlines. For example output of
should be
Code: Select all
O S, GOMR YPFSU/
O S, GOMR YPFSU/
Code: Select all
I AM FINE TODAY.
I AM FINE TODAY.
10082--runtime error
Code: Select all
#include<stdio.h>
int main()
{
long long i;
char a[300],str[1000000],sym;
a['W']='Q';
a['E']='W';
a['R']='E';
a['T']='R';
a['Y']='T';
a['U']='Y';
a['I']='U';
a['O']='I';
a['P']='O';
a['[']='P';
a[']']='[';
a['\\']=']';
a[' ']=' ';
a['1']='`';
a['2']='1';
a['3']='2';
a['4']='3';
a['5']='4';
a['6']='5';
a['7']='6';
a['8']='7';
a['9']='8';
a['0']='9';
a['-']='0';
a['=']='-';
a['S']='A';
a['D']='S';
a['F']='D';
a['G']='F';
a['H']='G';
a['J']='H';
a['K']='J';
a['L']='K';
a[';']='L';
a['\'']=';';
a['X']='Z';
a['C']='X';
a['V']='C';
a['B']='V';
a['N']='B';
a['M']='N';
a[',']='M';
a['.']=',';
a['/']='.';
gets(str);
while (str[i])
{
str[i]=sym;
putchar(a[sym]);
i++;
}
return 0;
}
i get RE ...... can anyone tell me y ??