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 1404. Easy to Hack!

Compilation error
Posted by Romow Peter 30 Nov 2006 18:17

#include <iostream.h>
#include <stdio.h>

using namespace std;

int main()
{
  char * s;
  cin >> s;

  int a[200] = {5};
  for (int i = 0; i < strlen(s); i++)
    a[i+1] = (s[i] - 'a');
  int n = strlen(s);

  for (int i = n; i >= 1; i--)
  {
     a[i] -= a[i-1];
     if (a[i] < 0) a[i] += 26;
  }

  for (int i = 1; i <= n; i++)
    cout << (char)(a[i]+'a');

}

why compilation error!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Re: Compilation error
Posted by AndrewSt(ArcSTU) 30 Nov 2006 23:38
Your solution was compiled with the following errors:

ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b
ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(4): error: name must be a namespace
name
  using namespace std;
                  ^

ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(9): warning #592: variable "s" is used
before its value is set
  cin >> s;
         ^

ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(12): error: identifier "strlen" is
undefined
  for (int i = 0; i < strlen(s); i++)
                      ^

ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(14): error: identifier "strlen" is
undefined
  int n = strlen(s);
          ^

ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b(25): warning #1: last line of file
ends without a newline
  }
   ^

compilation aborted for ed6aec59-24bf-4ca4-9cb3-cd499eb9bf3b (code 2)
Re: Compilation error
Posted by AndrewSt(ArcSTU) 30 Nov 2006 23:38
Your compiling code--

#include <iostream.h>
#include <stdio.h>
#include <string.h>


int main()
{
char * s;
cin >> s;

int a[200] = {5};
for (int i = 0; i < strlen(s); i++)
a[i+1] = (s[i] - 'a');
int n = strlen(s);

for (int i = n; i >= 1; i--)
{
a[i] -= a[i-1];
if (a[i] < 0) a[i] += 26;
}

for (int i = 1; i <= n; i++)
cout << (char)(a[i]+'a');

};
Re: Compilation error
Posted by Nikolai Besschetnov 1 Nov 2008 00:17
and dont forget std namespace.