|
|
вернуться в форумОбщий форумI used two different compilers at home, but here, I get compilation error! Послано Marko 30 апр 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! 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! 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! 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. |
|
|