C :: Use Recursion To Permutate Scores

Feb 8, 2013

I have this problem set that has to use recursion to permutate scores. I have read in all the numbers and have tested that it works . l have also attached what I have so far. Here is what I think I need to do:I have to pass the structs into this permutation algorithm that is here:

Code:
#include <stdio.h>
void ListPermutations(char str[]);
void RecursivePermute(char str[], int k);
void ExchangeCharacters(char str[], int i, int j);

[Code]....

View 1 Replies


ADVERTISEMENT

C++ :: Read Scores From File And Displays All The Scores

Aug 19, 2014

Okay so suppose that a text file grade.txt contains an unspecified number of scores. How would I program that reads the scores from the file and displays all the scores, their total and average? Scores are stored in the format of one score per line. Im having trouble with the whole #include <fstream> file and how to lay it all out in visual studio.

View 1 Replies View Related

C++ :: If And Else Statements With Game Scores

Oct 20, 2014

I am in comp. Sci 1 at my school and I have to write a program that deals with gamer scores and the trophy they get according to expert level. For example Tom is a beginner and gets a gold medal if >=10000 a silver >= 7500 bronze if >= 5000 and no trophy if he score <5000 ! I have do this scoring for Beginner, Immediate and Expert.

Should I set up the beginning like this:

case'b':
case 'B':
if (score >= 10000 )
trophy= gold
if (score >= 7500)
trophy = silver
if (score >= 5000)
trophy= bronze
else = none

Not really sure how to go about solving this problem

View 4 Replies View Related

C++ :: Display Scores On Notepad

Mar 16, 2014

I have a problem on my program. I want to display the scores on notepad. I can display it but the problem is every time I play the game the previous score got erased and replaced by the new one.Here's my code.

cout<<" Enter your name: ";
cin>>a;
cout<<endl<<endl;
cout<<" Your name is "<<a<<" and your score is "<<right<<endl<<endl;
ofstream MyFile ("score.txt");
MyFile << a <<" "<<right;
MyFile.close ();

View 4 Replies View Related

C++ :: Getting Test Scores Using Pointers

Jan 12, 2014

I'm trying to basically have a user input the amount of test they want averaged, then have the user input the test scores. Send the test scores to a function and have them ordered in ascending then send it to another function that averages it. When I wrote the function I keep getting the address back instead of the actual values.

#include <iostream>
#include <iomanip>
using namespace std;
void arrSelectSort( int* [], int);
void arrAverage(int);

[Code] .....

View 3 Replies View Related

C++ :: How To Calculate Number Of Scores Above 90

Apr 7, 2013

I have a program that allows the user to enter a specific number of test scores. Based on these test scores, the program should display the average score and calculate how many of the scores were above 90. I have most of it done but I'm having trouble figuring out how to calculate the number of scores that were above 90. What am I doing wrong?

This is my code:

#include <iostream>
#include <iomanip>
using namespace std;
// Function prototypes
double average(double*, int);
int howManyA(double*, int);

[Code]...

View 1 Replies View Related

C++ :: How To Store Test Scores

Jan 25, 2015

i have so far, and im having trouble finding a way to store 5 test scores for each student that has been entered. for example: enter name: chaotic enter id number: 12312312

Enter test score 1:
Enter test score 2:
Enter test score 3 etc.......

heres me code so far

#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
using namespace std;

[Code]....

View 1 Replies View Related

C/C++ :: Program That Scores Blackjack Hand?

Jun 5, 2014

Write a program that scores a blackjack hand. In blackjack, a player receives from two to five cards. The cards 2 through 10 are scored as 2 through 10 points each. The face cards - jack, queen, and king are scored as 10 points. The goal is to come as close to a score of 21 as possible without going over 21. Hence, any score over 21 is called "busted". The ace can count as either 1 or 11, whichever is better for the user. For example, and ace and a 10 can be scored as either 11 or 21. Since 21 is a better score, this hand is scored as 21. An ace and two 8s can be scored as either 17 or 27. Since 27 is a "busted" score, this hand is scored as 17.

The user is asked how many cards she or he has, and the user responds with one of the integers 2,3,4, or 5. The user is then asked for the card values. Card values are 2 through 10, jack, queen, king, and ace. A good way to hande input is to use the type char so that the card input 2, for example, is read as the character '2', rather than as the number 2. Input the values 2 through 9 as the characters '2' through '9'. Input the values 10, jack, queen, king, and ace as the characters 't', 'j', 'q', 'k', and 'a'. (Of course, the user does not type in the single quotes.) Be sure to allow upper - as well as lowercase letters as input.

After reading in the values, the program should convert them from character values to numeric card scores, taking special care for aces. The output is either a number between 2 and 21 (inclusive) or the word Busted. Use fucntions, multiway branches, switch statements or nested if-else statements. Your program should include a loop that lets the user repeat the calculation until they are done doing so.

The code runs properly for the first card but then it asks if the user wishes to repest the program. I need to claculate the value of all cards before it asks for that. Here is my code:

#include <iostream>
using namespace std;
int main()
{

[Code].....

View 5 Replies View Related

C/C++ :: Function To Read Scores Into Array?

Apr 16, 2015

I am currently in a beginner C programming class. I have written most of my code and the problem that I am running into when i compile and run the code. I am able to input more than required scores for input. I think my code is wrong from line 126-136. The program runs fine with no errors. I'm just unable to input the required number of scores allowed.

/*************************************************************************
* A program to calculate grade.
*************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

[Code].....

View 2 Replies View Related

C/C++ :: Average Scores For Diving Competition

Aug 27, 2014

float total, avg, max, min;
float judge[4];
int index;
int array[2];
int main() {
total = 0.0;

[Code] ....

At a diving competition, the mark given to each diver is awarded as follows:

There are a number of judges and each judge gives a mark and the final mark is found by leaving out the highest mark and the lowest mark and calculating the average of the rest.

Write a C program that reads in the number of judges at the competition and then reads in a mark for each judge. Perform the necessary calculations and display the highest mark, the lowest mark and the final mark.

The following data checks must be carried out in the program:

a)the number of judges must be from 4 to 8

/>each judge can give a mark from 0.0 to 10.0 (a real number that may include fractions)

If an invalid amount is entered, the program must ask for an acceptable value to be entered instead.

Note: this program does not need an array. However, you can use an array if you want to.

View 6 Replies View Related

C++ :: Structures - Keeping High Scores Of Users

Jun 1, 2013

Write a program that allows a user to enter high scores of a game, keeping tracking of the name of the user and the score. Add the ability to show the highest score for each user, all scores for a particular user, all scores from all users, and the list of users.

This is the program I am trying to write, however I am having difficulty storing the users name and high score, I know I need to store an array for the score but getting confused because of the structure. (By the way I have to use structures as it is a problem from the structures chapter of the ebook I am doing). Below is my code so far. .

Code:

#include <iostream>
#include <string>
using namespace std;
struct highScore
{
string user;
int score;
int highestScore;
int allScores;

[Code]...

View 9 Replies View Related

C++ :: Dynamic Array Allocation For Test Scores

Nov 30, 2014

I was doing a side programming challenge in my workbook that asked me to dynamically allocate and array for test scores. So far I have an array that will accept an integer to allocate the amount of test scores and then will accept integers to populate the array, however when I try to cout the contents of the array the numbers are absurdly different than what was put in. Here's my code:

#include "stdafx.h"
#include <iostream>
using namespace std;
void main() {
cout << "How many test scores?" << endl;
int scores(0);

[Code] ....

And this is the output screen:
How many test scores?
4
Enter test score 1:
22
Enter test score 2:
33
Enter test score 3:
44
Enter test score 4:
55
-33686019
18472
55656634
201345063
Press any key to continue . . .

Why am I getting these crazy numbers? I've looked back and forth from examples in my book and it doesn't look like I'm doing anything wrong.

View 5 Replies View Related

C++ :: Read Data From A File - Show Max And Min From Scores

Feb 26, 2013

My program reads data from a txt file and it displays the test scores and the sum of the scores, and it also shows the max and min from the scores , so far only one number shows up from the scores instead 10 and i think my sum is wrong too, but i cant get the max and min to work ...

#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
void openfile(ifstream &infile);

[Code] .....

View 17 Replies View Related

C++ :: Compute Mean And Standard Deviation From A Set Of 10 Random Scores

Nov 18, 2014

I have to write a program in which it is to compute the mean and standard deviation from a set of 10 random scores between 1 and 20. The C++ program should generate a set of scores randomly and then, compute the mean and standard deviation from such a set of scores.

View 2 Replies View Related

C/C++ :: Highest And Lowest Scores Of A Series Of Test Taken

Oct 22, 2014

I was asked to create a C++ program that allows a user to take a test with series of different questions, and also retake the test if they choose to. I have been able to do that. But the other condition is to display the highest and lowest scores (highest and lowest correct answers) the user got, and in which test they got that score. For example, if the user takes the test 3 times, in which test did they get the highest score, and in which did they get the lowest score.

This is how far I went with the program. The code below only let the user take the test as much as they want, and tell them how many times they took it, and the last score they had. My idea is this, if I can make a variable store each test score, then I can compare them. But since there is no definite number of tests to be taken.

#include <iostream>
#include <string>
using namespace std;  
void main() {
       int correct = 0;
       int wrong = 0;

[Code] .....

View 3 Replies View Related

Visual C++ :: Get Program To Read From File Of 15 Scores?

Dec 10, 2014

I'm trying to get the program to read from a file of 15 scores. 10 are quizzes 5 are exams. I want my program to read from the input file the first name "or" last name and if the user puts a different name, the program Gives off an error screen message

Code:
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
const int NUM_STUDENTS = 20;
const int NUM_QUIZZES = 10;
const int NUM_EXAMS = 5;

[code]....

View 14 Replies View Related

C# :: Algorithm With Recursion Use

May 12, 2014

To construct and write down algorithm of determination of the sum of squares of consecutive integers with recursion use. I tried to do something:

public static int RecSumSquare(int x, int n)
{
if (n < 0) throw new ArgumentException("n should be greater than zero");
if (n == 0) return 0;
else return x*x+RecSumSquare(x, n - 1);
}

But I don't know as the beginning and the end of this algorithm will look.

View 2 Replies View Related

C/C++ :: How To Decipher Recursion

May 4, 2014

Suppose I'm given the following code:

int mystery(int n){

int something;
if(n > 0)

View 1 Replies View Related

C :: Using Arrays - Program That Prompts For And Reads In Test Scores

Feb 11, 2013

Write a program that prompts for and reads in test scores. You may assume that valid test scores will be integer values between 0 and 100. You may also assume that the user will not enter more than 35 test scores. Use a preprocessor directive to define this value. User input will be complete when the user enters a -1 for the test score. When all of the test scores have been entered, the program will print out the scores. Use a while or do-while loop to read in the values. Use a for loop to print out the values.

Sample output:
Enter test score 1: 88
Enter test score 2: 67
Enter test score 3: 74
Enter test score 4: 94
Enter test score 5: 79
Enter test score 6: 56
Enter test score 7: -1
Number of scores entered: 6
Test scores entered : 88 67 74 94 79 56

View 14 Replies View Related

C :: Sorting List Of Students Based On Their Test Scores

Jan 18, 2014

I need to sort these students based on their test scores.

My biggest problem is with my sort function. I am not sure of the syntax to call the items the proper way. I also don't know how to call the function properly as I know that i can't pass a int to a struct. Also not sure about the z malloc. Just threw that one in there.

Code:
struct student{
int id;
int score;
};
void sort(struct student* students, int n){
/*Sort the n students based on their score*/

[Code] ....

View 5 Replies View Related

C++ :: Test Scores Program With Pointers - Calculate Average?

Apr 7, 2013

I have created a program that allows for a user-defined number of test scores as input. After the user enters these scores, the program calculates the average test score. Here is my code:

#include <iostream>
#include <iomanip>
using namespace std;
// Function prototypes
double getAverage(double*, int);

[Code] .....

I am having trouble with the final part of my program. How do I pass the array of test scores to a function that calculates how many people got an A (90+) on the test? The final output should look like this:

The average of those scores is:
The number of A grades is:

View 2 Replies View Related

Visual C++ :: Creating A Function That Needs To Determine Perfect Scores

Jun 24, 2013

This program is incomplete as I am having difficulty creating the function that needs to find the number of perfect scores entered by the user. I have everything but the function complete ,here is my code:

Code:
// Write a modular program that accepts at least 10 integer test scores from the user and stores them in an array.
// The main should display how many perfect scores were entered (i.e., scores of 100), using a value-returning countPerfect function.
// Input validation: Do not accept scores less than 0 or greater than 100.

#include <iostream>
using namespace std;
int countPerfect(int intArray[], int); // Function prototype

[Code] ....

View 14 Replies View Related

C++ :: Return A Node Using Recursion

Mar 27, 2013

So the task is to find the node with minimum value of a binary tree (not binary search tree). the input is the pointer to the root of the tree. and i cannot make recursion work when i do if conditions. here is what i have Code: ​/*function 3-takses as input the pointer to the root of the tree and returns a pointer to the node with the minimum value*/

CPPtr minimumvalue(CPPtr SP){
CPPtr min = NULL; //node of minimum value
if(SP== NULL){ // if there is a node, begin comparing
return NULL;
}
else{
if(SP->data<SP->left->data){ //if the node has smaller value than its left child
min = SP; //update node of minimum value

[code].....

no matter where i call my function i get errors like unhandled exception at some memory. how to use recursion in this?

View 6 Replies View Related

C++ :: File Recursion Limitation?

Apr 28, 2013

It seems that boost's file recursion requires that the file using the recursion must be in the include path. This makes using file recursion in a library header a problem as libraries may be located in a subdirectory of an include path (which is minor since the programmer can state the subdirectory in the recursive file call as long as it is not relative to the calling file). I also found it a problem when the main compile directory isn't in the compile path.

View 9 Replies View Related

C++ :: Want To Return A Node Using Recursion

Mar 28, 2013

So the task is to find the node with minimum value of a binary tree (not binary search tree). the input is the pointer to the root of the tree. and i cannot make recursion work when i do if conditions. here is what i have

CPPtr minimumvalue(CPPtr SP){
CPPtr min = NULL;//node of minimum value

if(SP== NULL){// if there is a node, begin comparing
return NULL;

[Code] ....

No matter where i call my function i get errors like unhandled exception at some memory. How to use recursion in this?

View 1 Replies View Related

C++ :: Recursion To Loop Using Stack

Oct 15, 2014

I want to convert the following program into a non-recursive code using a stack and a loop:

void write(int n) {
if (n>0) {
write(n-1);
cout << n << " ";
write(n-1);
}
}

And here is the code I am using but that currently does not work, and I do not know why:

stack<int> S;
S.push(n);
while (not S.empty()) {
int k = S.top();

[Code] .....

How to simulate that recursion. I thought it was enough to push into the stack the equivalent recursive call.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved