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

Common Board

I used two different compilers at home, but here, I get compilation error!
Posted by Marko 30 Apr 2005 06:21
Here is the code in Dev-C++:

#include <iostream.h>
#include <stdlib.h>
#include <string>
#ifdef ONLINE_JUDGE
running on timus
#endif
using std::cout;
using std::cin;
using std::string;
int faktorijel(int x, int y)
{

           if (x == 0 || x < 0)
              return  1;
           else
           {
               return x * faktorijel(x-y, y);
           }
}
int main()
{
      int a;
      int s = 0;
      string b;
      cout << "Write an integer:"," ";
      cin >> a;
      cout << "Write factorial marks:";
      cin >> b;
      for (int i = 0; i < 50; i++)
      {
          if (b[i] == '!')
             s++;
      }

      cout << faktorijel(a, s)<< endl;
      cout << endl;
      system("PAUSE");
      return 0;
}
And here isthe code in Borland C++:


#include <iostream.h>
#include <stdlib.h>
#include <string>
#ifdef ONLINE_JUDGE
running on timus
#endif
/* using std::cout;
using std::cin; */
using std::string;
int faktorijel(int x, int y)
{

           if (x == 0 || x < 0)
              return  1;
           else
               return x * faktorijel(x-y, y);
}
void main()
{
      int a;
      int s = 0;
      string b;
      cout << "Write an integer:"," ";
      cin >> a;
      cout << "Write factorial marks:";
      cin >> b;
      for (int i = 0; i < 50; i++)
      {
          if (b[i] == '!')
             s++;
      }

      cout << faktorijel(a, s)<< endl;
      system("PAUSE");
}

Most interesting is that my problem 1000 (for debils) doesn't work!:

/* Dev-C++ */
#include <iostream.h>

int main()
{

    long i;
    long j;
    long s;
    s = 0;
    cout <<"Input i";
    cin >> i;
    cout << "Input j";
    cin >> j;
    s = i + j;
    cout << s;
    return 0;
}
Re: I used two different compilers at home, but here, I get compilation error!
Posted by Problemset Maintainer 30 Apr 2005 12:58
Marko wrote 30 April 2005 06:21
int main()
{

    long i;
    long j;
    long s;
    s = 0;
    cout <<"Input i";
    cin >> i;
    cout << "Input j";
    cin >> j;
    s = i + j;
    cout << s;
    return 0;
}

Delete these lines:

cout <<"Input i";
cout << "Input j";
Re: I used two different compilers at home, but here, I get compilation error!
Posted by Marko Bogdan 1 May 2005 01:56
Yes, Timus doesn't understand this:
string b;
cin >> a;
cin >> b;
for (int i = 0; i < 50; i++)
{
if (b[i] == '!')
s++;
}

he want's little bit of this:

      char b[50];
      scanf("%s",b);
      s = strlen(b);
Re: I used two different compilers at home, but here, I get compilation error!
Posted by Problemset Maintainer 1 May 2005 02:33
Marko Bogdan wrote 1 May 2005 01:56
Yes, Timus doesn't understand this:
string b;
cin >> a;
cin >> b;
for (int i = 0; i < 50; i++)
{
if (b[i] == '!')
s++;
}
This should work. Plaese, post the whole source.