2,712 Posted Topics
Re: [quote] How to find the product of two matrix ? [/quote] The tittle should instead be : How to use Google [URL="http://lmgtfy.com/?q=multiplying+two+matrix"]Properly[/URL] If you know how to multiply 2 matrices with for loops then you know how to do with with other types of loop, provided you know about the … | |
Re: It seems like you are trying to make a code to send somebody a harmful .exe. Therefore I will not tell you. If i am wrong then say so, trusting you not to lie. | |
Re: There are basically the same except for their accuracy. A float is for example the following : [code] float F = 3.1415f; [/code] And a double is the following : [code] double D = 3.1415; [/code] As you can see they are similar, the only difference comes when accuracy is … | |
Re: Show more code. | |
Re: [code] for(int i = 1; i <= 10; i++) { for(int j = 1; i <= i; j++) System.print(j); System.println(); }[/code] | |
Re: [code] vector<string> words(); words[0] == "roller coasters"; words[1] == "waiting"; words[2] == "people who talk on the phone while driving"; words[3] == "wars"; [/code] You haven't allocated any memory for the vector. Try this : [code] vector<string> words(4); //Create 4 elements for now words[0] == "roller coasters"; words[1] == "waiting"; … | |
Re: I think you might be thinking about a wrapper. It is a function that wraps another function in a way that it makes it easier to use for the users. | |
Re: Why ? Maybe something like this : [code] #include <iostream> #include <string> using std::cout; using std::string; using std::endl; namespace Curious { string mystery = "Magic"; struct Wonder { Wonder(string msg) { mystery = msg; } }; } int main() { using namespace Curious; cout<<mystery<<endl; Wonder why("What is going on ? … | |
Re: 1) Use code tags. 2) This is incorrect : [code] for (int row = 0; row > maxRow; row++) [/code] It should be : [code] for (int row = 0; row [b]<[/b] maxRow; row++) [/code] You have that mistake in other places, such as both of your constructors. Fix it, … | |
Re: Here you go : [code] #include <iostream> #include <ctime> //for clock() using std::cout; void Delay(float milliSeconds) { const float clk_strt = float(clock()); while( clock() - clk_strt < milliSeconds ) continue; } int main() { for(int i = 0; i < 10; i++) { Delay(1000); //1000 milli seconds = 1 seconds … | |
Re: Here is a recursion that prints a message n number of time. Its not been tested. [code] void PrintUsingRecursion(string msg, int howMany) { if(howMany <= 0) return; //BASE CASE cout<<msg<<endl; PrintUsingRecusion(msg,howMany-1); } [/code] | |
Re: [QUOTE=bbballin;1000011]sorry i forgot to post my code [CODE] #include <stdio.h> int main() { int i ; int c; while ( ( i = getchar() ) != EOF ) c++ ; printf( "%d characters\n" , c) ; return 0; } [/CODE] does this seem ok? ... when i run it ./a.out … | |
Re: From the google [URL="http://en.wikipedia.org/wiki/Bubble_sort"]God[/URL] himself. | |
Re: [QUOTE=xfreebornx;1001522][TEX]Hello please how can i get a pointer value that is in for loop???[/TEX][/QUOTE] [TEX]Why are you talking like this?[/TEX] | |
Re: [quote] [CODE]#include<iostream> using namespace std; int main() { char name[10]= ""; // empty string int counter = -1; while (strcmp(name, "stop") != 0) { cout<<"Enter your friend's name (""stop"" to quit): "; cin>>name; counter++; } if (counter == 0) { cout<<"Go Make some friends you emotional loser!\n"; } else { … | |
Re: the cctype header has a function called isdigits(...). You can use that to validate whether a string contains integer. There are also isspace(..) among other things in that library. Check out the library , [URL="http://www.cplusplus.com/reference/clibrary/cctype/"]here[/URL] Here is an example : [code] #include<iostream> #include<cctype> using namespace std; int main() { string … | |
Re: [code] //For positiver integers thats within range of int int RecursiverMult( int x, int y) { //if y is less than 1 then return 0 //else return x plus RecursiveMult(x,y-1); } [/code] | |
Re: You should google, " sorting arrays". There are many algorithms for this task. Or you can let std::sort do the job. | |
Re: Its because you are not overriding the assignment operator. The virtual function needs to have the same signature, for a derived class of that of a ABC class or a base class. Just replace your pony operator with this : [code] void operator=(const Horse& rHorse) {itsAge = rHorse.GetAge(); std::cout<<"Pony operator= … | |
Re: [QUOTE=niek_e;1000491]You [I]could[/I] make the search-algorithm yourself (and that would be fun), but you can also save yourself alot of trouble and let std::sort do it for you. - load all numbers in a vector with two loops - std::sort them - print them out - done for example: [CODE=cplusplus]#include <iostream> … | |
Re: another way : [code] char RanChar = char('A' + rand()%26) [/code] | |
Re: Why not : [code] bool isEmpty() { return ( position.size == 0 ); } [/code] | |
Re: Something like this : [code] vector<short> cntr(10,0); // 0 through 10 elements initialize to 0 vector<short> value(10,0); // same as above; for(int i = 0; i < value.size(); i++) cin >> value[i]; //then you know the value is between the ranges of 0 to 9, and realize //that when user … | |
Re: Think in similar manner. Its not complete. [code] #include<iostream> using namespace std; int main() { int X = 0; int Y = 0; int Z = 0; cin >> X >> Y >> Z; if(X < Y) { if( X < Z ) { cout << X << " "; … | |
Re: [URL="http://reconnetworks.net/forum/index.php/topic,1701.0.html"]Link[/URL] | |
Re: You know using sstream is a lot easier : [code] #include<iostream> #include<sstream> using namespace std; int main() { int NumberToReverse = 123456; string str = ""; stringstream sstrm; sstrm << NumberToReverse; sstrm >> str; //str = "123456"; int i = str.length() - 1; cout<<NumberToReverse <<" reversed is : "; for( … | |
Re: [QUOTE=Lerner;1000107]To my knowledge you can't specify what to inherit and what not. You either inherit the whole shebang or you don't inherit anything. I always am receptive to being shown wrong, and thereby learn in the process, however.[/QUOTE] You know I wasn't 100% sure. Then I tried it. Tell me … | |
Re: 1) Use a string for input. 2) Check if all is numbers. 3) Output the string reverse. | |
Re: Create two int variable. Ask user for input Check if input is valid if so the proceed else go back to get user input start a for loop from i = 0; i < L; start another loop ( nested loop ) that ranges from j = 0; k < … | |
Re: if( variable is equal to a Number ) the do this code; Translation : [code] if( temp == -173 ) //do stuff [/code] what you are doing is this : if ( assign a number to temp ) //then do this Translation : [code] if( temp = 100) //do stuff; … | |
Re: sort the array. And from there see which value occurs the most. | |
Re: [QUOTE=ajeet choudhary;999250]hello......sir and madam.......... i m new for this site so please help and tell me how i can share my problem with you...... sorry for waste your time . thanks[/QUOTE] To share your problem, just post the problem. Ask specific question. Maybe google it before you ask question, in … | |
Re: Something like this ? : [code]#include <iostream> #include <vector> #include <string> using std::string; using std::cout; using std::endl; using std::cin; class RationalNumbers { private: float Numerator ; float Denominator ; public : RationalNumbers() { } template<typename T> RationalNumbers(const T& RationalNumbers); }; template<typename T> RationalNumbers::RationalNumbers(const T& var){ cout<<typeid(T).name()<<" specialized\n"; } template<> RationalNumbers::RationalNumbers(const … | |
Re: I would recommend to use [code] void foo(data_type * Array, int Size), [/code] | |
Re: To have a fixed floating point decimal add this code : [code] cout.setf(std::ios_base::fixed,std::ios_base::floatfield); [/code] [URL="http://www.cplusplus.com/reference/iostream/ios_base/setf/"]http://www.cplusplus.com/reference/iostream/ios_base/setf/[/URL] | |
Re: I think you are looking for a general answer, but its hard to tell without seeing the code, so post relevant code, or if small enough, the whole code. | |
| |
Re: Pop each element. Check if there are equal matching braces/brackets... | |
It uses the idea of Seive of Eratosthenes. The code is basically does the following to find Prime Numbers : 1) Populate Array from 0 - > MAX 2) Find 1st Prime, which is 2 3) Delete all Multiple of 2, i.e set it to false 4) Find next prime, … | |
Re: [code] cout.setf(std::ios_base::fixed, std::ios_base::floatfield); [/code] See your other post. Just put this inside main, near the beginning. | |
Re: I am guessing you are a senior in high school. Beginning, you will take course such as : calculus, physics, chemistry, cse101(intro to programming, language depends), and some general education class, maybe history. The as time goes on, you will get more into the programming areas. The school should provide … | |
Re: Yes its possible to cut that picture into correct portion and paste it onto a 2d tile. You need to first create a nxn tile set. Then, you need to generate the correct texture coordinate for each tile. You could calculate the texture coordinate by having 4 variables, float bottomLeft, … | |
Re: Example : [code] #include <iostream> using namespace std; int main() { int val[4] = {1,2,3,4}; int limit = 2; for(int i = 0; i < limit; i++) { cout<<"Enter value : "; cin >> val[i] } return 0; } [/code] | |
Re: Here is something that will start you off : [code] #include<iostream> using namespace std; int main() { //Create a variable for : // Min number the user can input //Max number the user can input //The number of guesses //The winning number //use random number generator to assign the winning … | |
Re: total = distance / mpg * ppg + parking + tolls; or total = distance / ( mpg * ppg + parking + tolls ); ??? | |
Re: Can you post code. I think you have multiple definition, or non proper linking. | |
Re: Haven't used it for a while, but I think it takes the ascii value in int form. if you wan't to use variable use a char variable [code] char print ='0'; for(print = '0'; print != '9'; print++) glutStrokeCharacter(GLUT_STROKE_MONO_ROMAN, print); [/code] Also google the function, and you get a documentation, … | |
Re: yes sure you can. For example you might have a reset method that resets everything to a default constructor : [code] class A { int c; public : A() { c = 1000; } A(int x ) { c = x; } void reset() { *this = A(0); } }; … | |
Re: You're thinking too hard. [code] string src = "hello" for(int i = src.length()-1; i >= 0; i--) cout<<src[i]; [/code] |
The End.