49,761 Topics
| |
#include <iostream> #include <cmath> // appropriate c++ libraries for functions & constants needed #include <fstream> #include <stdlib.h> using namespace std; const int N = 1000; const double pi = 3.14159265; //constants applied int main() { double num, factor, avg = 1.0; //variables declared and initialised int i; num = N … | |
Hello, I have this matrix: 0 0 1 0 0 0 1 0 1 1 1 0 0 1 0 0 and I need to print out the block with the coords: (2,1) so in this case: 1 0 1 0 I have tried this: for(int i=minRow; (i < 2); … | |
I want to write a code to find all combinations of 4 numbers, for example numbers = 1,2,3,4 combinations are: 1 2 3 4 12 13 14 23 24 34 123 134 234 124 1234 Plz help i am unable to understand the logic... thanks in advance... | |
##I was working on something and saw this oddity, thought I would share it. $ ./a.out in.val = 86.3115158 -> Its a valid floating point number out1.val = nan -> Swapped it and now its a NaN! That's OK swap it back. out2.val = 86.4365158 -> What, its not the … | |
This code is supposed to respond on (w,s,a,d and q) key press..... On "w" the character ( actually the $ sign ) should move up similarly s =down , a is for left and d to move right.......... and 'q' is to quit!! Sometimes on a very few (beginning key … | |
Dear guys, I get stuck in a basic problem that is often overlooked. Like this , I can write code in such way. #include"stdio.h" void main(void){ double x; scanf("%f",&x); printf("%f",x); } When I input a number like 3.0 ,however the result is a minus number. I don't konw why ,anybody … | |
Having issues fixing these issues: error LNK2019: unresolved external symbol "public: __thiscall grid::grid(void)" (??0grid@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'GridObject''(void)" (??__EGridObject@@YAXXZ) F:\Dev103\thermonuclear war game\thermonuclear war game\Grid.obj error LNK1120: 1 unresolved externals F:\Dev103\thermonuclear war game\Debug\thermonuclear war game.exe 1 //header file #include <iostream> using namespace std; class grid{ int … | |
how do i get output which would normally appear on the screen, as in the Microsoft visual studio command prompt, written to a file such as a simple text file. say << X << is the output, what do i do from here? thanks | |
An office furniture company sells furniture in three colors: red, black and green. Every item in their inventory system has a 5-character code. The last two characters are always used to represent color. If an item is red, the last two characters are “41”. If an item is black, the … | |
This code is just a function in a bigger code, but I'm having a problem with the break. I'm not sure I'm doing it right, but basically if the factors are zero, then the program should say the equation can't be factored. It does that, but then continues through the … | |
Hello, I'm trying to determine where a small matrix would fit inside a big matrix.. But, the small matrix is not in the big matrix so I need to see how simular they are.. The one with the lowest value, is the best fit.. So my difference function is this: … | |
I am fairly new at C++ and Im having a lot of trouble understanding how to do it. This is part of a homework assignment due next week and I have no idea how to even start it (much less finish coding it). Can anyone out there help? ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Create … | |
This may sound really noobish, and I'm probably missing something really stupid.. But, I'm trying to calculate the differences between matrices, and the one with the smallest value (result) is the matching number.. But, for some reason my algorithm seems to be missing the smallest number and I can't figure … | |
This is probably a really simple and stupid question, but when I try to "Build and Run" an OpenGL program on XCode, it seems to debug it and open the window for a split second and then close. There aren't any compilation errors and it finishes saying that the debugging … | |
So, I'm playing around with SDL and I've come across a bit of a bump. I have one image and I am trying to "free" that image to put on another one. Here is what my code looks like.. [CODE] // I did get a good section of this code … | |
Hello, I'm creating a game using SDL, and what I'd like to happen is: if the character jumps on a button, then it'll disappear. However, I cannot find a way of accomplishing this, as all the SDL functions I know of start at runtime and cannot be changed. If I'm … | |
Hi, I'm trying to sort a list of names in c++ (first name and last name). I'm running into a couple of problems with my code. I'll post the code first then state my problems. #include <iostream> #include <stdio.h> #include <cstring> using namespace std; const int numNames=3;//this makes the code … | |
I am implementing RSA in C++ and here's my design(code structure). *keygen.h* namespace rsa{ class keygen{ public: //Constructor keygen(size); //Generate keys void generate(); //Getters string gete(){ return xyz; } .. .. .. private: //initializes bignums void initall(); keygen(){} //Private Member variables goes here } } *prime.h* namespace rsa{ //First 100 … | |
somebody pleae post some basic C++ excersices of loops.please help me i am a beginner. thANKSS | |
Hi i need help with moving a light. at the start of the program i define the floats. `GLfloat Light_Ambient[] = {0.7f, 0.7f, 0.7f, 255.0f};` `GLfloat Light_Diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};` `GLfloat Light_Position[]= {0.0f, 1.0f, 3.5f, 1.0f};` but later on in the program while the scene is running i … | |
I have not found anything that addresses these questions. Any help is appreciated. If I have a class that has pointers to objects of a user-defined class as members, is there any problem with initializing those pointers with the initialization list of the constructor? For example, where A, B, and … | |
Can anyone show or explain how to do a base conversions ? I'm new so this concept is confusing so far i got to but I have no clue to get answer from base 10 to any base 2 to base 16 #include <cstdlib> #include <iostream> #include <string> using namespace … | |
I have googled this and I see how to do the clock function with insertion and I was pretty sure I implemented it right but the insertion sort never shows any time. I am not sure if I am not waiting long enough but I have had the program up … | |
I'm sure I'm missing something basic here, but I cannot get this to compile. Using codeblocks 10.05 with mingw build of gcc 4.4.1. I've included unistd.h and tried replacing MAXPATHLEN with PATH_MAX but every time, it gives me: error: 'MAXPATHLEN' was not declared in this scope or error: 'PATH_MAX' was … | |
I have a question about istream iterators and reading the input to the EOL. How do you do it? I tried the following but had to revert to a hack to get it to work. My first attempt reads from the istream but a word at a time. first.cpp #include … | |
I'm trying to solve Problem #54 of Project Euler, which is basically evaluating poker hands. My program currently outputs 383, but the answer should be 376. My full code #include <iostream> #include <string> #include <fstream> #include <vector> #include <sstream> using namespace std; //CLUBS=14; //SPADES=15; //HEARTS=16; //DIAMONDS=17; int value(char str){ switch … | |
Hello, Could anyone explain details about three different case and output. Here is the code and output: #include <stdio.h> void foo(int n) { n = 6; } void fooWithRef(int& n) { n = 6; } int main() { int n; foo(n); printf("Case_1 Result: %d \n", n); n = 4; foo(n); … | |
The problem is simple. I have LoadLibrary on my c++ app and I want to load c# library but I don't know the entry point. | |
Hi, I have read something on IBM's site about exception specification and pointers to functions: void (*f)(); void (*g)(); void (*h)() throw (int); void i() { f = h; // h = g; This is an error. } IBM says: > The compiler allows the assignment f = h because … | |
Hi there!) Guys please tell me - where can I see the realization (or custom realization) of fprintf in C++ ? I'm especially interesed in working with no fixed number of passed parameters. I need to made somethings like fpintf() by myself but i don't know how.... big thanks in … |
The End.