I am trying to include all repetitions for just one turn but I keep getting
00.0 but I want (the one in red)
170.3 0 0.3
180.0 17 0.0
190.3 18 0.0
200.3 19 0.3
210.0 20 0.3
220.0 21 0.0
22 0.0
so basically I call a function that represents just one turn of getting a random number, and then when the player decides he wants to get a random number that is at least 17 and wants to repeat this 3x I have to print out this chart that shows the chances of the player rolling the numbers between 17-22 [how many times does he get 0,17,18,19,20,21,22] this is what I have
cout << "your score: " << (' ') << "chances for that score:" << endl;
/* score is the player's total score for the one turn */
int score = 0;
int score0 = 0; // 0
I have a main.h file where I include all the needed things to make my program compile properly, string, vector etc.
And I also have another header file which comntains a class that is used later in the code (globally), I decided to keep it in another file to make it more clear and easier.
I need to include that file in main.h, but I also include main.h from that class header file because it contains some other includes that are required to compile.
Is this a good thing? Or should I keep main.h out of that class header file and include just things required for the class?
I may have complicated it too much, so I'll show an example, what I do now:
// ---- main.h ---- #include <string> #include <vector> #include <ctime> // other includes, these are just examples #include "MyClass.h" // the separated class header file
[Code] ......
So, from what you can see MyClass.h requires just including the vector, but to avoid repeating myself I include main.h which does that already, but also includes MyClass.h
So, I have two questions: 1. Is it ok to include in that way (including a file that includes the including file) 2. Is it good to include a main header file with all the includes even if I just need one of them, or should I skip including main.h and include just the things my class requires (vector is just an example)
How would one cycle through a turn order in a turn-based game? I was thinking an array of every creature (including the player) and have a pointer to the array++ after the turn, but I couldn't put all the objects into an array.
I wrote a program for class. It did its job, but I want to make it better. The program finds all of the Pythagorean triples between 1 and 100.
As you can see, the program will repeat the same Pythagorean triples but in different orders.
What I want to do is have the program repeat each Pythagorean triple once, regardless of whether the ordering is different. I have tried, but only came up with the solution to solving repetition that is consecutive. But the repetition for Pythagorean triples jump around.
I got stuck on how to eliminate jumping repetitions. I only know how to make it not repeat on consecutive entries.
I wrote a program that finds the Pythagorean triples for class. It did its job, but I want to make it better. The program below finds all of the Pythagorean triples between 1 and 100.
As you can see, the program will repeat the same Pythagorean triples but in different orders.
What I want to do is have the program repeat each Pythagorean triple once, regardless of whether the ordering is different. I have tried, but only came up with the solution to solving repetition that is consecutive. But the repetition for Pythagorean triples jump around.
E.g., Pythagorean triple (6, 8, 10) appears. Then two Pythagorean triples later, (8, 6, 10) appears.
I got stuck on how to eliminate jumping repetitions. I only know how to make it not repeat on consecutive entries.
I nested one for loop, in another for loop that is nested in another for loop. One for loop for each of the values in the triple. The most nested loop is for the c value in a^2 + b^2 = c^2, and has an if statement: if( ((a*a)+(b*) == (c*c) ) , and then the program prints the numbers.
#include <iostream> #include <cmath> using namespace std; int main() { unsigned int a, b, c; char con; cout << "This program finds the pythagorean triples between 1 and 200.
Say you the user inputs x number of names and then is to put in x amount of values for each name. How would you display these values in a 2d array and be able to add the values for each row which will represent each name?
int main () { string integer1; string integer2; cout <<" enter your first number: " << endl; cin >> integer1; cout << endl; cout << integer1 << " is your first number" << endl; }
Now how do I turn the string integer into an array?
I'm having trouble trying to turn a word into letters. I've seen other posts but they deal with a sentence and it only outputs the words only. What I want to know is how do they take a word (Ex: "word") and break it into individual letters, where I want to store them in a vector of string?
If it's not too much trouble, I would prefer without using pointers or "std:: " marks, since I am trying to avoid pointers and I'm using "using namespace std" all the time.
Ex:
In the example "word", it should output into:
"w" "o" "r" "d"
and I will push them back into a vector of string where each vector element contains a letter.
I have a hpp file with a list of inline finctions like this:
Code: inline int check() { return 1; } inline int check_1() { return 1; }
... What I would like to do is to include them into several unrelated classes. How can I do this. Can I just add the hpp inline functions in headers of my class containing files or not. I mean if they are not defined as class functions how can they be called. I don't understan the logic.
When I attempt to compile the above code, I get several thousand errors, mostly "stray ‘@’ in program", coming from the cocoa framework. It compiles and runs correctly if I omit the cocoa include or if I name the file main.mm instead of main.cpp.
I'm pretty sure it's failing because cocoa is written in objective c and I'm reading it as c++ code..how to include an objective c file in a c++ program?
I know strings are essentially just arrays of characters, so what would be the easiest way to take each individual digit and put it into a separate space in an array?
I have the header (and accompanying lib file) in my project folder, I have it in my solution explorer. And I've tried to add it via C++ Directories.. but that doesn't seem to exist anymore, instead it points to a user property sheet, but where to find or access it ...
I am starting a turn based battle (similar to pokemon) app. How could i make this and make it cross platform. Also is it possible to make it access gps and allow other devices with the same app communicate with each other?
I have done things on the command line but i never made anything with images so i dont even know where to start for this app.
So basically it consists of implementing a single turn for the game called 'pig' and printing out scores and probabilities of those scores. So this is what I have thus far :
int randomNum (int min, int max) { return min + rand () % (max - min + 1); } int singleTurn (int holdValue) { int totalRoll = 0; int score = 0; do { score = randomNum(1,6);
I've worked a lot in Java and Perl and now I'm learning C++ and working on a simple e-reader (let's not get into why I'm not just using Kindle or other existing ones). This is for me and a number of friends.
At first my project will be on OS X, then Windows and Linux, and I hope to eventually use it on Android and iOS. I know that the last two will require separate GUIs, but I'm hoping the rest of the code will port easily.
Here's the problem:
I'm using Poppler to read and display PDF files. I started installing it on my iMac and it needs FontConfig, which is turning out to be a difficult install. I would not want to walk others through this or make them have to install Poppler and FontConfig (and any other libraries I find both need).
I thought I could just compile my final binaries using "-static" but I've been reading about how some libraries can't be statically linked or compiled.
Also, since I want to eventually port this to 4 other OSes (and apparently Poppler can work on those target OSes), I don't want to do something now or depend on something that will make it hard or impossible to port to other OSes later.
With that in mind, here are my questions:
1) Why is it some libraries cannot be compiled statically? How do I know if I'm dealing with one of those libraries?
2) Am I right that I could compile this program statically, and the resulting binary would include code from Poppler and FontConfig and other libraries would be included in the resulting executable binary?
3) What do I need to watch for so I can tell if using a particular library will be a problem when I need to port my program to a new OS? (Assuming, of course, that searching shows that library will compile or has been ported to that OS.)
I have four source files. The main source file includes two other source files. The two other source files both include the fourth source file. In the fourth source file I have an include guard. Will the code from the fourth source file exist in two locations in the compiled code? Is this something that is compiler dependent? An example of this is shown in the code below.
I have two report.h files located in two different directories. However the contents of them are different. How can I include the report.h file located in guarddog into the report.h file located in sky?
I am displaying data from an Excel Spreadsheet through an ASP.net web form using C#. I would like to run an SQL query on the data, but am having trouble figuring out how to use a string in my query.
Here is the code I am running in my .aspx.cs file. I am also using a .aspx to display the data in a GridView.
Ideally, I would like to add a WHERE clause to my string (string sSQL = "SELECT * FROM [Sheet1$A1:D14]"/> in order to query the current month and display the row of said month from the Excel Spreadsheet.
I have attempted to use a DataAdapter to insert the string into the query, but could not figure out how to conform my code to work with it.
I am currently developing a small quick'n dirty SIP (Session Initiation Protocol) parser. Its task is to read a file (or command-line argument) with a SIP requst and parse it using the sofia-sip library. It should exit either with "1" on parsing failure or "0" on parsing success.
I have taken the code snipplet from here: [URL] .... resulting in this source code:
I have defined to classes : Parent and Child. I have some global variables in a header file named as "var.h". These variables are used in both Parent and child Classes. The source code of these classes are written below:
Parent.h ============================================== #ifndef PARENT_H #define PARENT_H #pragma once #include <stdio.h> class Parent {
[Code] ....
After compiling, the compiler returns a fatal error as follows:
1>Parent.obj : error LNK2005: "int counter" (?counter@@3HA) already defined in Child.obj 1>C:Documents and SettingspishiDesktop estDebug est.exe : fatal error LNK1169: one or more multiply defined symbols found
It says the "counter" is defined multiple times....