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 1567. SMS-spam

WA#8
Posted by Tom 6 Aug 2011 19:46
what s wrong this time ?
anybody ?


#include<iostream>
#include<string>

using namespace std;

char napis[1001]={0};

char tab[35]={0};
int tab1[35]={0};

int main(){
tab[0]=*"a"; tab1[0]=1;
tab[1]=*"b"; tab1[1]=2;
tab[2]=*"c"; tab1[2]=3;
tab[3]=*"d"; tab1[3]=1;
tab[4]=*"e"; tab1[4]=2;
tab[5]=*"f"; tab1[5]=3;
tab[6]=*"g"; tab1[6]=1;
tab[7]=*"h"; tab1[7]=2;
tab[8]=*"i"; tab1[8]=3;
tab[9]=*"j"; tab1[9]=1;
tab[10]=*"k"; tab1[10]=2;
tab[11]=*"l"; tab1[11]=3;
tab[12]=*"m"; tab1[12]=1;
tab[13]=*"n"; tab1[13]=2;
tab[14]=*"o"; tab1[14]=3;
tab[15]=*"p"; tab1[15]=1;
tab[16]=*"q"; tab1[16]=2;
tab[17]=*"r"; tab1[17]=3;
tab[18]=*"s"; tab1[18]=1;
tab[19]=*"t"; tab1[19]=2;
tab[20]=*"u"; tab1[20]=3;
tab[21]=*"v"; tab1[21]=1;
tab[22]=*"w"; tab1[22]=2;
tab[23]=*"x"; tab1[23]=3;
tab[24]=*"y"; tab1[24]=1;
tab[25]=*"z"; tab1[25]=2;
tab[26]=*"."; tab1[26]=1;
tab[27]=*","; tab1[27]=2;
tab[28]=*"!"; tab1[28]=3;
tab[29]=*" "; tab1[29]=1;




    int i=0,j=0,k=0,licznik=0;
    cin.getline (napis, 1000);
    k = strlen(napis);
    for(i=k-1;i>=0;i--){
            for(j=0;j<30;j++){
                    if(napis[i]==tab[j]){
                               licznik+=tab1[j];
                               }
                    }
            napis[i]=0;
            }
    cout << licznik;
    getchar();
    return 0;
}

Re: WA#8
Posted by Navid 10 Nov 2011 13:51
Change 1000 to 1001 !!!!
Re: WA#8
Posted by cena 30 Nov 2012 14:58
salam navid,dasdet dard nakone AC gereftam!!!!
cena.
Re: WA#8
Posted by Pavel 2 Jan 2013 14:24
Thanks, Navid!
Re: WA#8
Posted by Savichev 12 Oct 2014 01:01
Thx, but i can not understand why this has helped)
After two minutes I realized ... '\0' symbol :D

Edited by author 12.10.2014 01:03