- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 2
- Posts with Upvotes
- 2
- Upvoting Members
- 2
- Downvotes Received
- 3
- Posts with Downvotes
- 2
- Downvoting Members
- 3
6 Posted Topics
Re: OMG... Try this code: [CODE=cpp]#include <iostream.h> #include <assert.h> #include <stdlib.h> enum TokenType { tkOpen, tkPlus, tkMinus, tkMult, tkDiv, tkClose, tkNumber, sizeTokenType }; const char chars[sizeTokenType] = { '(', '+', '-', '*', '/', ')', ' '}; const int priority[sizeTokenType] = {0, 1, 1, 2, 2, 5, 10}; template <class T> class … | |
Re: Do you mean something like this: [CODE=cpp]void fibonacci(int i, int & result) { if(i < 2) result = 1; else { int prev, prev_prev; fibonacci(i - 1, prev); fibonacci(i - 2, prev_prev); result = prev + prev_prev; } } int main() { int n; fibonacci(6, n); cout << n << … | |
Re: Try something like this: [CODE=C] printf("n="); scanf("%d",&n); /* <--- You should get address here !!! */ for (x = 1; x <= n; x++) { for(y = 1; y <= n - x + 1; y++) printf("%d",y); printf("\n"); } [/CODE] | |
Re: It's about [B]all-access checking[/B] ([URL="http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/C_002b_002b-Dialect-Options.html"]3.5 Options Controlling C++ Dialect[/URL] for additional info). Go to Project -> Project Options -> Compiler -> C++ Compiler and set "Turn off all access checking option" to [B]No[/B]. This will disable your warning. | |
Re: Try this code: [CODE=C] for(i = 0; i < len; i++) { r = r * 2 + (bin[i] == '1' ? 1 : 0); }[/CODE]or [CODE=C] for(i = 0; i < len; i++) { r = r * 2 + (bin[i] - (int)'0'); }[/CODE] | |
Re: [QUOTE]can i declare operator overloading function as a friend function?[/QUOTE]You can, but you need function woth two parameters: [CODE=cpp]friend time operator + (time& left, time& right);[/CODE] |
The End.