Search:

Type: Posts; User: 0rion

Page 1 of 7 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    2,179

    Close try, but you don't necessarily need to...

    Close try, but you don't necessarily need to return anything on the reverse function as you can just modify the array inside the function and it'll be affected in the main function. You can reduce...
  2. Replies
    7
    Views
    12,245

    It's rather simple due to the directed acyclic...

    It's rather simple due to the directed acyclic nature of the problem we are guaranteed no cycles in the graph. Hence a simple DP algorithm suffices. We first define the DP state to be:

    F(x) = the...
  3. Thread: how to sort ?

    by 0rion
    Replies
    6
    Views
    1,234

    [ #include #include ...

    [

    #include <cstdio>
    #include <iostream>
    #include <vector>
    #include <algorithm>
    #include <utility>
    using namespace std;

    vector< pair<int,int> >arr;
  4. Replies
    6
    Views
    1,974

    Alternatively if you are required to retrieve the...

    Alternatively if you are required to retrieve the n-th largest number - sorting is an option. Just sort and iterate through on the sorted list.
  5. Replies
    8
    Views
    1,476

    Not sure if this will help but try placing the...

    Not sure if this will help but try placing the function inside namespace std.
  6. Thread: unbelievable!!!

    by 0rion
    Replies
    13
    Views
    1,733

    Well 110*110 = 12100 basic operations (I'm...

    Well 110*110 = 12100 basic operations (I'm assuming the inner loop doesn't do much though), which is hardly much for a modern computer. Try doing at least 5 million basic operations and the std::cout...
  7. Replies
    17
    Views
    1,992

    This is platform dependent issue - you need to...

    This is platform dependent issue - you need to turn it off in a terminal/shell or using a system-dependent function.
  8. Replies
    16
    Views
    5,098

    Ah okies - I snipped the code out for the time...

    Ah okies - I snipped the code out for the time being :)
  9. Replies
    16
    Views
    5,098

    Of course you can use STL functions to simplify...

    Of course you can use STL functions to simplify them - but then he won't learn how loops are used :)
  10. Replies
    9
    Views
    1,607

    #include #include #include...

    #include <iostream>
    #include <vector>
    #include <string>
    #include <algorithm>

    using namespace std;

    void print(const vector<int>& vec) {
    int table[26];
    memset(table,0,sizeof(table));
  11. Replies
    3
    Views
    1,190

    #include #include #include...

    #include <iostream>
    #include <vector>
    #include <string>

    using namespace std;

    int main()
    {
    string text, search, replacement, res;
    getline(cin,text); getline(cin,search);...
  12. Replies
    16
    Views
    5,098

    Snipped ;) Note you still need to modify...

    Snipped ;)


    Note you still need to modify this. Notably in the calcAverage() function - you wanted the top 4 however in this case it gets the average of all the inputted scores. Also, if you want...
  13. Replies
    8
    Views
    1,705

    #include using namespace std; int...

    #include <iostream>
    using namespace std;

    int main() {
    int n = 8;
    while ((n+17)/(n-7) >= 2) {
    if ((n+17)&#37;(n-7) == 0) cout << n << "\n";
    n++;
    }
    return 0;
  14. Replies
    9
    Views
    2,166

    Not sure if you are asking if you can do it...

    Not sure if you are asking if you can do it without creating a "dynamic" array or not, but in case you are asking if you can do it via a static array you can simply just do:



    #include <vector>...
  15. Replies
    3
    Views
    1,289

    Expanding upon what ZuK said, basically the...

    Expanding upon what ZuK said, basically the access control level determines the access levels for the derived class.

    So if you want all the access levels to be the same as what is in the base...
  16. Replies
    1
    Views
    5,051

    Using reverse iterators in algorithms

    Hey, I've been having some trouble with getting reverse iterators to work along with the standard algorithms. Since they only accept a normal iterator I can't do any computation using a reverse...
  17. Thread: Read from string

    by 0rion
    Replies
    6
    Views
    1,200

    I would probably try and create another function...

    I would probably try and create another function that converts hex to decimal that takes 2 characters and returns back the decimal value. You could use a mini-symbol table to link up 'A' to 10, 'B'...
  18. Thread: Read from string

    by 0rion
    Replies
    6
    Views
    1,200

    You need to use a loop to traverse through the...

    You need to use a loop to traverse through the string and extracting 2 characters until it reaches the end of the string.
  19. Replies
    5
    Views
    1,594

    Hmm I'm still slightly confused, wouldn't...

    Hmm I'm still slightly confused, wouldn't "strm(is)" call the constructor which takes a single std::istream argument (i.e. direct initialisation)? At the moment I can't visualise it properly (still...
  20. Replies
    5
    Views
    1,594

    Constructor Initialiser List

    Ok, I'm having a weird problem with getting my code to compile. The compiler (g++) keeps telling me that the "copy constructor" is private and gives me "error: within this context". Here's my...
  21. Thread: Echoing a File

    by 0rion
    Replies
    2
    Views
    1,437

    Thanks that cleared it up totally :)

    Thanks that cleared it up totally :)
  22. Thread: Echoing a File

    by 0rion
    Replies
    2
    Views
    1,437

    Echoing a File

    So I wanted to echo a file into standard output through the use of stream iterators, but I encountered an unexcepted output when I used strings compared to characters. Here's my code with chars...
  23. Replies
    3
    Views
    1,114

    Ahhhh! I didn't see it coming! :( *hides in the...

    Ahhhh! I didn't see it coming! :(
    *hides in the shadows*

    I quickly coded it so I didn't pay much attention to the variable names as I just wanted to learn the maps! Thanks for the input.. guess I...
  24. Replies
    3
    Views
    1,114

    Mismatching parameters

    I'm having a small problem with "matching up" the function definition/prototype with the function definition. I've stared at the code for ages already and can see no clue in where I'm at fault. The...
  25. Replies
    5
    Views
    2,912

    char *b[3]; b is an array of 3 elements of...

    char *b[3];

    b is an array of 3 elements of character pointers. If you use 'b' you really mean
    the address of the first element (i.e. &b[0]). When you attempt to use b++,
    you are telling the...
Results 1 to 25 of 175
Page 1 of 7 1 2 3 4