10197 - Learning Portuguese
Moderator: Board moderators
10197 PE!! plz help
i am getting PE for this code. I am not sure about the spaces. plz help.
#include<stdio.h>
#include<iostream.h>
#include<string.h>
int main()
{
char str1[100],str2[100],str3[100],ch=243;
int i,j,k,len;
while(cin>>str1>>str2)
{
cout<<str1<<' '<<"(to "<<str2<<")"<<endl;
len=strlen(str1);
if(str1[len-1]=='r'&&str1[len-2]=='a')
{
strcpy(str3,str1);
str3[strlen(str3)-2]='o';
str3[strlen(str3)-1]='\0';
cout<<"eu "<<str3<<endl;//9 spaces
strcpy(str3,str1);
str3[strlen(str3)-1]='s';
cout<<"tu "<<str3<<endl;//9 spaces
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
cout<<"ele/ela "<<str3<<endl;//4 spaces
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
strcat(str3,"mos");
str3[strlen(str3)]='\0';
cout<<"n"<<ch<<"s "<<str3<<endl;//8 spaces
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
strcat(str3,"is");
str3[strlen(str3)]='\0';
cout<<"v"<<ch<<"s "<<str3<<endl;//8 spaces
strcpy(str3,str1);
str3[strlen(str3)-1]='m';
cout<<"eles/elas "<<str3<<endl;//2 spaces
}
else if(str1[len-1]=='r'&&str1[len-2]=='e')
{
strcpy(str3,str1);
str3[strlen(str3)-2]='o';
str3[strlen(str3)-1]='\0';
cout<<"eu "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='s';
cout<<"tu "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
cout<<"ele/ela "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
strcat(str3,"mos");
str3[strlen(str3)]='\0';
cout<<"n"<<ch<<"s "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
strcat(str3,"is");
str3[strlen(str3)]='\0';
cout<<"v"<<ch<<"s "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='m';
cout<<"eles/elas "<<str3<<endl;
}
else if(str1[len-1]=='r'&&str1[len-2]=='i')
{
strcpy(str3,str1);
str3[strlen(str3)-2]='o';
str3[strlen(str3)-1]='\0';
cout<<"eu "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-2]='\0';
strcat(str3,"es");
cout<<"tu "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-2]='e';
str3[strlen(str3)-1]='\0';
cout<<"ele/ela "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
strcat(str3,"mos");
str3[strlen(str3)]='\0';
cout<<"n"<<ch<<"s "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
strcat(str3,"s");
str3[strlen(str3)]='\0';
cout<<"v"<<ch<<"s "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-2]='\0';
strcat(str3,"em");
cout<<"eles/elas "<<str3<<endl;
}
else cout<<"Unknown conjugation"<<endl;
cout<<endl;
}
return 0;
}[/quote]
#include<stdio.h>
#include<iostream.h>
#include<string.h>
int main()
{
char str1[100],str2[100],str3[100],ch=243;
int i,j,k,len;
while(cin>>str1>>str2)
{
cout<<str1<<' '<<"(to "<<str2<<")"<<endl;
len=strlen(str1);
if(str1[len-1]=='r'&&str1[len-2]=='a')
{
strcpy(str3,str1);
str3[strlen(str3)-2]='o';
str3[strlen(str3)-1]='\0';
cout<<"eu "<<str3<<endl;//9 spaces
strcpy(str3,str1);
str3[strlen(str3)-1]='s';
cout<<"tu "<<str3<<endl;//9 spaces
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
cout<<"ele/ela "<<str3<<endl;//4 spaces
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
strcat(str3,"mos");
str3[strlen(str3)]='\0';
cout<<"n"<<ch<<"s "<<str3<<endl;//8 spaces
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
strcat(str3,"is");
str3[strlen(str3)]='\0';
cout<<"v"<<ch<<"s "<<str3<<endl;//8 spaces
strcpy(str3,str1);
str3[strlen(str3)-1]='m';
cout<<"eles/elas "<<str3<<endl;//2 spaces
}
else if(str1[len-1]=='r'&&str1[len-2]=='e')
{
strcpy(str3,str1);
str3[strlen(str3)-2]='o';
str3[strlen(str3)-1]='\0';
cout<<"eu "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='s';
cout<<"tu "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
cout<<"ele/ela "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
strcat(str3,"mos");
str3[strlen(str3)]='\0';
cout<<"n"<<ch<<"s "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
strcat(str3,"is");
str3[strlen(str3)]='\0';
cout<<"v"<<ch<<"s "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='m';
cout<<"eles/elas "<<str3<<endl;
}
else if(str1[len-1]=='r'&&str1[len-2]=='i')
{
strcpy(str3,str1);
str3[strlen(str3)-2]='o';
str3[strlen(str3)-1]='\0';
cout<<"eu "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-2]='\0';
strcat(str3,"es");
cout<<"tu "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-2]='e';
str3[strlen(str3)-1]='\0';
cout<<"ele/ela "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
strcat(str3,"mos");
str3[strlen(str3)]='\0';
cout<<"n"<<ch<<"s "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-1]='\0';
strcat(str3,"s");
str3[strlen(str3)]='\0';
cout<<"v"<<ch<<"s "<<str3<<endl;
strcpy(str3,str1);
str3[strlen(str3)-2]='\0';
strcat(str3,"em");
cout<<"eles/elas "<<str3<<endl;
}
else cout<<"Unknown conjugation"<<endl;
cout<<endl;
}
return 0;
}[/quote]
ur output format is not correct. ur output format should follow the output specification.Here u can output like this
You must print a blank line between the output sets , not after each output sets.
Hope this helps.
Code: Select all
cout << str1 << " (to " << str2 << ")" << endl;
cout << "eu " << s << endl;
cout << "tu " << s << endl;
cout << "ele/ela " << s << endl;
cout << "n" << c <<"s " << s << endl;
cout << "v" << c <<"s " << s << endl;
cout << "eles/elas " << s << endl;
Hope this helps.
hi mmonish,
Actually i gave all the blank spaces properly as you mentioned. that means my output format is exactly like
but i am not sure why my code is not showing those blank spaces in the electronic board!!!
in the board its not showing any blank spaces after
eu, tu, ele/ela...... that's funny,isn't it?
Actually mmonish i am not getting your line
You must print a blank line between the output sets , not after each output sets
would you plz explain it more? here i am not sure which segment is output sets? i think for each input there is a output, and this output is a set,isn't it? like the output generated for "falar talk" is an output set,am i right? i am confused where to place blank line. plz help. Thanks.
Actually i gave all the blank spaces properly as you mentioned. that means my output format is exactly like
Code: Select all
cout << str1 << " (to " << str2 << ")" << endl;
cout << "eu " << s << endl;
cout << "tu " << s << endl;
cout << "ele/ela " << s << endl;
cout << "n" << c <<"s " << s << endl;
cout << "v" << c <<"s " << s << endl;
cout << "eles/elas " << s << endl;
![:o](./images/smilies/icon_eek.gif)
eu, tu, ele/ela...... that's funny,isn't it?
Actually mmonish i am not getting your line
You must print a blank line between the output sets , not after each output sets
would you plz explain it more? here i am not sure which segment is output sets? i think for each input there is a output, and this output is a set,isn't it? like the output generated for "falar talk" is an output set,am i right? i am confused where to place blank line. plz help. Thanks.
u have to print a blank line after each test case but not after the last one.
here is an example not from the prob
I hope u will get the point.
here is an example not from the prob
Code: Select all
input
1
2
output
55
66
-
- New poster
- Posts: 38
- Joined: Tue Jul 17, 2007 3:21 pm
- Location: East West University
10197 - Runtime Error
Hi all,
I'm getting runtime error don't know the reason :| Don't know if i'm calling anything wrong but i don't think so...
Thanks
I'm getting runtime error don't know the reason :| Don't know if i'm calling anything wrong but i don't think so...
#include<stdio.h>
#include<string.h>
#include<malloc.h>
char * calcSufixo(char *strPt);
char * calcRoot(char *strPt);
void presentVerb(char *root,char *sufixo,char *strEn);
int main(){
char strPt[30];
char strEn[30];
char input[31];
char *sufixo;
char *root;
int first=0;
while(fgets(input,sizeof(char)*31,stdin)!=NULL){
if(first!=0)
printf("\n");
first++;
input[strlen(input)-1]='\0';
sscanf(input,"%s %s",strPt,strEn);
sufixo=calcSufixo(strPt);
root=calcRoot(strPt);
presentVerb(root,sufixo,strEn);
}
return 0;
}
void presentVerb(char *root,char *sufixo,char *strEn){
char o=243;
printf("%s%s (to %s)\n",root,sufixo,strEn);
if(strcmp(sufixo,"ar")==0){
printf("eu %so\n",root);
printf("tu %s%cs\n",root,sufixo[0]);
printf("ele/ela %s%c\n",root,sufixo[0]);
printf("n%cs %s%cmos\n",o,root,sufixo[0]);
printf("v%cs %s%cis\n",o,root,sufixo[0]);
printf("eles/elas %s%cm\n",root,sufixo[0]);
}
else if(strcmp(sufixo,"er")==0){
printf("eu %so\n",root);
printf("tu %s%cs\n",root,sufixo[0]);
printf("ele/ela %s%c\n",root,sufixo[0]);
printf("n%cs %s%cmos\n",o,root,sufixo[0]);
printf("v%cs %s%cis\n",o,root,sufixo[0]);
printf("eles/elas %s%cm\n",root,sufixo[0]);
}
else if(strcmp(sufixo,"ir")==0){
printf("eu %so\n",root);
printf("tu %ses\n",root);
printf("ele/ela %se\n",root);
printf("n%cs %s%cmos\n",o,root,sufixo[0]);
printf("v%cs %s%cs\n",o,root,sufixo[0]);
printf("eles/elas %sem\n",root);
}
else
printf("Unknown conjugation\n");
}
char * calcSufixo(char *strPt){
char *sufixo=malloc(sizeof(char)*2);
sufixo=&strPt[strlen(strPt)-2];
return sufixo;
}
char * calcRoot(char *strPt){
int sizeRoot=strlen(strPt)-2;
char *root=malloc(sizeof(char)*sizeRoot);
strncat(root,strPt,strlen(strPt)-2);
return root;
}
Thanks
Re: 10197 - Learning Portuguese
Code: Select all
import java.io.*;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static int[] intBuffer = new int[0];
static int intBufferPos = 0;
static double[] doubleBuffer = new double[0];
static int doubleBufferPos = 0;
static StringBuilder outputBuffer = new StringBuilder(10000);
static Scanner scanner = new Scanner(new BufferedInputStream(System.in));
static int[] readIntArr() throws Exception {
while(true) {
String line = readLine();
if(line == null)
return null;
else if(line.equals(""))
continue;
else return toIntArr(line);
}
}
static int[] toIntArr(String str) {
if(str.equals(""))
return new int[0];
String strArr[] = toStrArr(str);
int intArr[] = new int[strArr.length];
for(int i=0; i<strArr.length; i++)
intArr[i] = toInt(strArr[i]);
return intArr;
}
static int readInt() throws Exception {
while(intBufferPos >= intBuffer.length) {
intBuffer = readIntArr();
intBufferPos = 0;
}
return intBuffer[intBufferPos++];
}
static int toInt(String str) {
return Integer.parseInt(str);
}
static long toLong(String str) {
return Long.parseLong(str);
}
static double[] readDoubleArr() throws Exception {
while(true) {
String line = readLine();
if(line == null)
return null;
else if(line.equals(""))
continue;
else return toDoubleArr(line);
}
}
static double[] toDoubleArr(String str) {
if(str.equals(""))
return new double[0];
String strArr[] = toStrArr(str);
double doubleArr[] = new double[strArr.length];
for(int i=0; i<strArr.length; i++)
doubleArr[i] = toDouble(strArr[i]);
return doubleArr;
}
static double readDouble() throws Exception {
while(doubleBufferPos >= doubleBuffer.length) {
doubleBuffer = readDoubleArr();
doubleBufferPos = 0;
}
return doubleBuffer[doubleBufferPos++];
}
static double toDouble(String str) {
return Double.parseDouble(str);
}
static String[] toStrArr(String str) {
StringTokenizer st = new StringTokenizer(str);
String strArr[] = new String[st.countTokens()];
int i=0;
while(st.hasMoreTokens()) {
strArr[i++] = st.nextToken();
}
return strArr;
}
static String[] readStrArr() throws Exception {
while(true) {
String line = readLine();
if(line == null)
return null;
else if(line.equals(""))
continue;
return toStrArr(line);
}
}
static String readLine() throws Exception {
return br.readLine();
}
static boolean isEmpty(String s) {
return (s == null || s.equals(""));
}
static void flush() {
System.out.print(outputBuffer.toString());
outputBuffer = new StringBuilder(10000);
}
static void print(int n) {
outputBuffer.append(n);
}
static void print(long n) {
outputBuffer.append(n);
}
static void print(char ch) {
outputBuffer.append(ch);
}
static void print(String s) {
outputBuffer.append(s);
}
static void println() {
outputBuffer.append("\n");
}
static void println(int n) {
outputBuffer.append(n + "\n");
}
static void println(long n) {
outputBuffer.append(n + "\n");
}
static void println(double n) {
outputBuffer.append(n + "\n");
}
static void println(String s) {
outputBuffer.append(s + "\n");
}
static int max(int a, int b) {
return (a>=b ? a : b);
}
static int min(int a, int b) {
return (a<b ? a : b);
}
static int max(int[] intArr) {
int max = intArr[0];
for(int i=1; i<intArr.length; i++) {
if(intArr[i] > max)
max = intArr[i];
}
return max;
}
static long abs(long n) {
return Math.abs(n);
}
static void myassert(boolean b) throws Exception {
if(!b)
throw new Exception("BAD");
}
public static void main(String args[]) throws Exception {
boolean newline = false;
while(true) {
String line = readLine();
if(line == null) break;
int space = line.indexOf(" ");
String verb = line.substring(0, space).trim();
String meaning = line.substring(space + 1).trim();
if(newline)
println();
else newline = true;
println(verb + " (to " + meaning + ")");
int len = verb.length();
if(len < 2) {
println("Unknown conjugation");
continue;
}
String root = verb.substring(0, len-2);
String lastTwoChar = verb.substring(len-2);
char tv = ' ';
if(lastTwoChar.equals("ar")) {
tv = 'a';
} else if(lastTwoChar.equals("er")) {
tv = 'e';
} else if(lastTwoChar.equals("ir")) {
tv = 'i';
} else {
println("Unknown conjugation");
continue;
}
String a = (root + "o");
String b = (tv == 'i' ? root + "es" : root + tv + "s");
String c = (tv == 'i' ? root + "e" : root + tv);
String d = (root + tv + "mos");
String e = (tv == 'i' ? root + tv + "s" : root + tv + "is");
String f = (tv == 'i' ? root + "em" : root + tv + "m");
println("eu " + a);
println("tu " + b);
println("ele/ela " + c);
println("n" + (char)243 + "s " + d);
println("v" + (char)243 + "s " + e);
println("eles/elas " + f);
}
flush();
}
}
-
- New poster
- Posts: 37
- Joined: Wed Oct 03, 2007 10:42 am
Re: 10197 - Learning Portuguese
I think I am ok. But I am getting WA.
can anyone explain why?
I will be greatful to him.
Thanks
alamgir
can anyone explain why?
I will be greatful to him.
Code: Select all
#include<stdio.h>
#include<string.h>
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt","w", stdout);
char latin [ 40 ], english [ 40 ], str [ 100 ], *tok;
char pronoun [][ 50 ] = {"eu ","tu ","ele/ela ","nós ","vós ","eles/elas "},con1 [][ 10 ] = {"o", "as","a","mos","ais","am"}, con2 [][ 10 ]= {"o", "es","e","emos","eis","em"}, con3 [][ 10 ]= {"o", "es","e","imos","is","em"};
int i, len, kase = 0;
while( gets( str ) )
{
tok = strtok( str, " ");
strcpy( latin, tok );
tok = strtok(NULL, "");
strcpy(english, tok);
len = strlen( latin );
if( kase ) printf("\n"); kase = 1;
printf("%s (to %s)\n", latin, english);
if( latin [ len - 1 ] != 'r' || len < 2 )
{
printf("Unknown conjugation\n");
continue;
}
if( latin [ len - 2 ] == 'a' && latin [ len - 1 ] == 'r' )
{
latin [ len - 2 ] = '\0';
for( i = 0; i < 6; i ++)
{
printf("%s%s%s\n", pronoun [ i ], latin, con1 [ i ]);
}
}
else if( latin [ len - 2 ] == 'e' && latin [ len - 1 ] == 'r' )
{
latin [ len - 2 ] = '\0';
for( i = 0; i < 6; i ++)
{
printf("%s%s%s\n", pronoun [ i ], latin, con2 [ i ]);
}
}
else if( latin [ len - 2 ] == 'i' && latin [ len - 1 ] == 'r' )
{
latin [ len - 2 ] = '\0';
for( i = 0; i < 6; i ++)
{
printf("%s%s%s\n", pronoun [ i ], latin, con3 [ i ]);
}
}
else
{
printf("Unknown conjugation\n");
}
}
return 0;
}
alamgir
Re: 10197 - Learning Portuguese
I am getting WA too, and I dont know why!
Look out my code:
![:o](./images/smilies/icon_eek.gif)
Look out my code:
Code: Select all
#include <iostream>
#include <string>
using namespace std;
int main()
{
bool flag = 0;
string portuguese,english;
char tv;
while (cin >> portuguese >> english)
{
if (!flag)
flag = 1;
else
cout << endl;
cout << portuguese << " (" << "to " << english << ")" << endl;
if (portuguese.size() > 1)
{
tv = portuguese[portuguese.size()-2];
portuguese = portuguese.substr(0,portuguese.size()-2);
}
else
tv = 'x';
if (tv == 'a' || tv == 'e')
{
cout << "eu " << portuguese << 'o' << endl;
cout << "tu " << portuguese << tv << 's' << endl;
cout << "ele/ela " << portuguese << tv << endl;
cout << "n" << (char)243 << "s " << portuguese << tv << "mos" << endl;
cout << "v" << (char)243 << "s " << portuguese << tv << "is" << endl;
cout << "eles/elas " << portuguese << tv << 'm' << endl;
}
else if (tv == 'i')
{
cout << "eu " << portuguese << 'o' << endl;
cout << "tu " << portuguese << "es" << endl;
cout << "ele/ela " << portuguese << 'e' << endl;
cout << "n" << (char)243 << "s " << portuguese << tv << "mos" << endl;
cout << "v" << (char)243 << "s " << portuguese << tv << 's' << endl;
cout << "eles/elas " << portuguese << "em" << endl;
}
else
{
cout << "Unknown conjugation" << endl;
}
}
return 0;
}
Re: 10197 - Learning Portuguese
You can't use the "nos" and "vos" as copy-paste strings in the array. For them you have to use 243 explicitly.
Like this:
I think the reason for this is that 243 falls under the territory of "unsigned char". And if you use an array for the printing process then you can't STRLEN() on them using normal array pointing (or whatever).
Another problem I'm facing is that I'm getting AC only when I'm submitting in C++. In C, the same code is giving PE.
EDIT: Now I got AC in C too. The Unsigned Char issue is the thing. And strlen() can't calculate properly if string contains Unsigned Char.
Like this:
Code: Select all
for (i=0 ; i<6 ; i++) {
if (i==3) {
putchar('n'); putchar(243); putchar('s');
} else if (i==4) {
putchar('v'); putchar(243); putchar('s');
} else
printf("%s",t_rep[i]);
for (j=1 ; j<11-strlen(t_rep[i]) ; j++) {
putchar(' ');
}
printf("%s%s\n",str,c_rep[con][i]);
}
Another problem I'm facing is that I'm getting AC only when I'm submitting in C++. In C, the same code is giving PE.
EDIT: Now I got AC in C too. The Unsigned Char issue is the thing. And strlen() can't calculate properly if string contains Unsigned Char.
Re: 10197 - Learning Portuguese
I got WA with my code.
It has been a very frustrating experience.
It has been a very frustrating experience.
Code: Select all
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
char[] nos = {'n', 243, 's'};
char[] vos = {'v', 243, 's'};
String[][] conjugations = {{"eu", "tu", "ele/ela", new String(nos), new String(vos), "eles/elas"},
{"o", "as", "a", "amos", "ais", "am"},
{"o", "es", "e", "emos", "eis", "em"},
{"o", "es", "e", "imos", "is", "em"},};
String thematicVowels = " aei";
String pt, en;
int conjugation;
while (scanner.hasNextLine()) {
pt = scanner.nextLine();
conjugation = pt.indexOf(' ');
en = pt.substring(conjugation + 1);
pt = pt.substring(0, conjugation);
conjugation = thematicVowels.indexOf(pt.charAt(Math.max(pt.length() - 2, 0)));
System.out.println(pt + " (to " + en + ")");
if (conjugation == -1 || !pt.endsWith("r")) {
System.out.println("Unknown conjugation");
} else {
pt = pt.substring(0, pt.length() - 2);
for (int i = 0; i < 6; i++) {
print(conjugations[0][i], 10);
System.out.println(pt + conjugations[conjugation][i]);
}
}
if (scanner.hasNextLine())
System.out.println();
}
scanner.close();
}
private static void print(String s, int pad) {
System.out.print(s);
for (int i = 0; i < pad - s.length(); i++) {
System.out.print(' ');
}
}
}
Re: 10197 - Learning Portuguese
Tip 1: Test thesenguyenh3 wrote:I got WA with my code.
It has been a very frustrating experience.
Code: Select all
ir is there something wrong?
ar ar
falar what is this
namer coder
jubir jubir
Code: Select all
ir (to is there something wrong?)
eu o
tu es
ele/ela e
nós imos
vós is
eles/elas em
ar (to ar)
eu o
tu as
ele/ela a
nós amos
vós ais
eles/elas am
falar (to what is this)
eu falo
tu falas
ele/ela fala
nós falamos
vós falais
eles/elas falam
namer (to coder)
eu namo
tu names
ele/ela name
nós namemos
vós nameis
eles/elas namem
jubir (to jubir)
eu jubo
tu jubes
ele/ela jube
nós jubimos
vós jubis
eles/elas jubem
Code: Select all
unsigned char t_rep[6][30]={"eu","tu","ele/ela","nós","vós","eles/elas"};
Then I used the exceptions n243s and v243s but still WA
Then
Code: Select all
char t_rep[6][30]={"eu","tu","ele/ela","nós","vós","eles/elas"};
Then I did
Code: Select all
char t_rep[6][30]={"eu","tu","ele/ela","nss","vss","eles/elas"};
I think strlen() has some prob with that or something. Hope this info helps. I understand how damn frustrating it can get.
Re: 10197 - Learning Portuguese
I see what you mean - that the English word doesn't necessarily start one space after the Portuguese word. So I added a trim() function which takes out all trailing spaces (before and at the end of the string).Tip 1: Test these
Code: Select all
ir is there something wrong? ar ar falar what is this namer coder jubir jubir
I still get WA.
Java doesn't have unsigned variables. I'm pretty confident the String.length() counts correctly all characters, including (char) 243.
I really appreciate your input to my problem though. Thanks.
Re: 10197 - Learning Portuguese
I finally got AC with Java... (I hate this problem.
)
Some things about Java:
1. In Java, char is always unsigned.
2. Java will automatically encodes the output to your default character set.
For example, "Big5" is for Traditional Chinese, "GB18030" is for Simplified Chinese, "KOI8-R" is for Russian.
I guess the most used encoding of Windows PCs is "UTF-8".
However, the on-line judge I/O is encoded in "ISO-8859-1".
For Java users, I got AC by the code like this:
![:-?](./images/smilies/icon_confused.gif)
Some things about Java:
1. In Java, char is always unsigned.
2. Java will automatically encodes the output to your default character set.
For example, "Big5" is for Traditional Chinese, "GB18030" is for Simplified Chinese, "KOI8-R" is for Russian.
I guess the most used encoding of Windows PCs is "UTF-8".
However, the on-line judge I/O is encoded in "ISO-8859-1".
For Java users, I got AC by the code like this:
Code: Select all
StringBuffer buf = new StringBuffer();
OutputStreamWriter cout = new OutputStreamWriter(System.out, "ISO-8859-1");
// your code here
cout.write(buf.toString());
cout.flush();
Re: 10197 - Learning Portuguese
Thank you annhy, my solution was finally accepted.
This shouldn't be an issue at all.
This shouldn't be an issue at all.