C++ :: How To Make A Loop That Keeps Track Of Whose Turn It Is And Their Score
Dec 11, 2013[URL] ....
This is my code, but how can I implement this?
[URL] ....
This is my code, but how can I implement this?
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.
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.
View 2 Replies View Relatedi have to make a score average, minimum, maximum as statistics for the out file. here is the code i have done:
Code: #include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
[Code].....
I need starting a do-while loop in my program that runs up to 10 time that asks the user to enter up to 10 scores, which include the slope and rating for the course, and calculates the handicap for each score. Here's what I have so far:
//This program calculates a golfers handicap.
#include <iostream>
#include <string>
using namespace std;
int main(){
int score, slope;
double rating, handicap;
[Code] ....
#include <stdio.h>
float total, avg, max, min;
float judge[4];
int index;
int array[4];
int main() {
total = 0.0;
max = array[0];
min = array[0];
[Code] ....
I dont understand how to make the array when it prints out only print out the final average and the final maximum score with the final minimum score but what its doing at the moment is just giving an average for each individual score taken...
Minimum and maximum scores are displaying 0.0
And it displays these things 4 times in a row i just want it to be displayed once.
I'm trying to write a program for a lab, I know how easy it is but cant see to crack it.
I need to make a program using while or for loop.
I must have the user type a number, for an input value an output value but then do it again several times but without it going on forever asking again and again.
How to make a loop so program never end, it end only by typing "EXIT"
View 1 Replies View RelatedI'm trying to optimize this code using openMP. The line I added made it run about twice as fast but I'm trying to figure out how to make it even faster. Could reshaping the loops potentially increase the speed?
//4 threads
int listsize=15000;
#pragma omp parallel for shared(f) private(i,j,hash)
for(i = 0; i < listsize; i++) {
printf("Thread: %d i: %zu wl_size: %zu
",omp_get_thread_num(),i,wl_size);
for (j = 0; j < num; j++) {
h = f[j] (getw(list, i));
c[h] = 1;
} }
I need to do make a loop inside a condition. Can it be done? I don't want to call another function to do it. Any way at all without calling separate function inside the if? I just want to do:
if (
for (int i = 0; i<=10; i++)
{
//stuff related to the for loop
} )
{
//stuff related to the initial if condition
};
I have an exam in C programming I'm a little stuck on loops..I have to make a program that multiplies the loop variable by 2 then takes away 1... easy, that was a for loop no problem
for (x=3; x<=65; x=x*2-1)
that should print out 3 5 9 17 33 65 however, my lecturer has given the task for it to reverse, but not to display the number 17 on the way back down using an if statement...however, this time it must be a do while loop... This is what I have so far.
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int x = 129;
}
[code]....
I'm making a program for a MMO I play. It calculates the cash and resources needed to build certain 'modules'. I'm having trouble to do something very simple : make a loop until the user asks to break the loop. Here is what the interface looks like :
What module do you want to install?
(Examples: 'Avenger' or 'VLLT')
dd // I input this
DD. COST each : 60,000 cr.
How many do you want? (Modules left:15)
(NOTE : You may enter a negative number if you made a mistake)
3 // I input this
Current Total Module Price : 180000 cr
+6 droids
[Code] ....
The bigger code box below is a part of the code I made. What I deleted is uninteresting, it's just the same thing again : other resources, other 'modules'...
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
struct resources// Defines the amount of resources and their price
[Code] ....
Something that does something like this
at this point run a loop for all players, in this loop use random to determine the face and depending on the face run a loop (for roll again etc) or give next user the chance.
And this loop is 2-12 people, all rolling die.
They draw 3 die out of a cup of 12.
Then they roll the 3 die, getting fish, hook, or boot on each die.
I'm working on a code that needs to loop a switch case back to the beginning after a certain input is entered.
ex) Code:
printf("Select an option);
printf("1. Play game");
printf("2. Status");
printf("3. Exit");
scanf("%i", &userinput);
switch(userinput);
[Code]...
For my program, I want option 2 to display something, then loop back to "select and option" after the user presses enter. How would I write that? Would i use a while? do while?
Write a program to make a table for any input number and then continuesly ask to press y to print more table and if you press any key other than y then program must be terminate using while loop and do while loop. How to start or end with it.
View 2 Replies View RelatedMy while loop is the problem. I want to use a non-recursive function to make the triangle number the sum of all whole numbers from 1 to N.
#include "stdafx.h"
#include <iostream>
using namespace std;
int triangle(int t);
[Code] ....
I have to make a function that i'll later be able to use for a ceasar cypher. The letters should shift a user inputted number. This is what I have so far:
char shiftChar(char c, int s) {
char ch = c;
int shift = s;
int newC;
newC = int(ch) + shift;
return newC;
}
The problem with this, is that it doesn't loop back to the start of the alphabet once i get past z.
I have this code which performs the analysis part of discrete wavelet transform. It works pretty well. However, I wish to reduce the time that it consumes even further. I did use reserve() and it worked upto few msec.
int rows = signal.size();
int cols = signal[0].size();
int cols_lp1 =(int) ceil( (double) cols / 2);
vector<vector<double> > lp_dn1(rows, vector<double>(cols_lp1));
vector<double> temp_row;
temp_row.reserve(512);
[Code] ....
I am currently trying to read information from an ID3V1.1 tag in C. For this project we are not allowed to use any external libraries. All of the fields except for the track field read correctly. The last two lines are the ones giving me trouble. Whenever I run the program, I get a seg fault when it tries to get the track number. I tried to debug using gdb and it said the problem was happening on line 34 which is where the fseek is. It works for the other fields so I'm wondering why it is going wrong. Should I change the offset to something other than -128? But the whole tag is only 128 characters so I'm unsure what is going wrong.
Code:
Program received signal SIGSEGV,
Segmentation fault.0x00000034ff66edf1 in fseek() from / lib64 /
libc.so .6 Missing separate debuginfos,
use:debuginfo - install glibc - 2.12 - 1.132.el6_5 .3.x86_64(gdb) back
#0 0x00000034ff66edf1 in fseek () from /lib64/libc.so.6
#1 0x000000000040076f in main (argc=1, argv=0x7fffffffdf58) at id3tagEd.c:34 Code: Code: #include<stdio.h>
#include<string.h>
}
[code]...
I want to create an object that uses visual C#'s Numeric Up/Down and a Track bar.
The reason is that I have a GUI that uses lots of these linked together with events and I want a common event handler for all of them.
Maybe just adding a property that is a Numeric Up/Down in the Track bar and vice-versa will allow me to create a common event for all of these pairs.
i am trying to make a hangman game. The game works fine so far but i cannot seem to keep track of the letters used. I have to prevent the user from using a letter that has already been entered by the user at some point in the game before. But can't seem to work my way around it. I have included the code below
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<ctime>
[Code].....
The reason being is that it says that my program is right
Code:
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define NFlights 10
struct date {
int month;
int day;
int year;
int hour;
int minute;
[Code] ....
map< int, int > cache;
int count( int n ){
if( cache[n] != 0 ){
return cache[n];
[Code] ....
I don't know how to turn this recursive function into an iterative...
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
[Code]....
does a pointer keep track of time stamps when it is created? i am trying to use it to create a table that can store the access count and the temporal locality at the same time.
View 5 Replies View RelatedI would like to track user actions within my windows desktop application, and write them to a database.
I also have a User class, that has a userID field pulled from the User table. I can write a login event (UserID, timestamp, action) with no problem, but as the user navigates around the app, how can I persist the user object so I always have access to their userID? I know I can just pass it as a parameter as they do different tasks, but that seems inefficient to me.