fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #define n 10
  5. using namespace std;
  6.  
  7.  
  8. int T[ N ];
  9. int suma( int n )
  10. {
  11. if( n == 0 )
  12. {
  13. return T[ 0 ];
  14. }
  15. else
  16. {
  17. return suma( n - 1 ) + T[ n ];
  18. }
  19. }
  20.  
  21. int main()
  22. {
  23. srand( time( NULL ) );
  24. int znak;
  25. for( int i = 0; i < N; i++ )
  26. {
  27. if( rand() % 10 < 5 )
  28. {
  29. znak =- 1;
  30. }
  31. else
  32. {
  33. znak = 1;
  34. }
  35. T[ i ] = znak * rand() % 100;
  36. cout << T[ i ] << " ";
  37. }
  38. cout << suma( 9 )
  39.  
  40. return 0;
  41. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:8:8: error: 'N' was not declared in this scope
 int T[ N ];
        ^
prog.cpp:4:11: error: expected ',' or '...' before numeric constant
 #define n 10
           ^
prog.cpp:9:15: note: in expansion of macro 'n'
 int suma( int n )
               ^
prog.cpp: In function 'int suma(int)':
prog.cpp:13:16: error: 'T' was not declared in this scope
         return T[ 0 ];
                ^
prog.cpp:17:32: error: 'T' was not declared in this scope
         return suma( n - 1 ) + T[ n ];
                                ^
prog.cpp: In function 'int main()':
prog.cpp:25:25: error: 'N' was not declared in this scope
     for( int i = 0; i < N; i++ )
                         ^
prog.cpp:35:9: error: 'T' was not declared in this scope
         T[ i ] = znak * rand() % 100;
         ^
prog.cpp:40:5: error: expected ';' before 'return'
     return 0;
     ^
stdout
Standard output is empty