can someone give me an idea please?
please... really need help..
http://cboard.cprogramming.com/attac...tid=6539&stc=1
Printable View
can someone give me an idea please?
please... really need help..
http://cboard.cprogramming.com/attac...tid=6539&stc=1
You're going to need to show that you can do a bit more work on your own first before anybody's going to give you any help.
Something you should do before asking for help is write a program that will analyse a number of commerce hands stored in a text file and determine which of the hands is the winning hand based on the definition given on that PDF.
If you do that, it should develop your skills in basic programming and problem solving.
Then post your question...
ops sorry, ok here is the code
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
string commerce;
ifstream myfile ("input2.txt");
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,commerce);
cout << commerce << endl;
}
myfile.close();
}
else cout << "Unable to open file";
system("pause");
return 0;
}
Ok... that's about the first 10 percent of the assignment. Look ok so far. Just don't use system("pause") you should use cin.get() if you need to pause the program. And don't control your loop with eof(). You're better off controlling the loop with the actual input statement.
any other tips .. i really get stuck..
You want a tip or a solution? Just give it your best shot... then when you run into a specific problem, we're glad to help.
Code:while ( getline (myfile,commerce) ) {
int score = getScoreForHand( commerce );
cout << "hand " << commerce << " scored " << score << endl;
}
First off is say print the names of the 3 cards - separate into tokensCode:int getScoreForHand( string &commerce ) {
return 0;
}
Then add something which assigns a value to each card
Then add something which scores the hand according to the rules
this is my code tat i have work for long time
can some one give me some useful hints...pleaseCode:
/*******************************************************************************
Commerce games(commerce.cpp)
This program will analyse a number of a commerce hands stored in a text
file and determine which of the given hands is the winning hand.
********************************************************************************/
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
using namespace std;
int main()
{
//declare numRows, numColumns and string
const int numRows = 6;
const int numColumns = 3;
string hands[numRows][numColumns];
//initialise the string and assign each to 'X'
for(int row = 0; row < numRows; row++)
{
for(int col = 0; col <numColumns; col++)
{
hands[row][col] = "X";
}
}
//input from input.txt and display
ifstream myfile ("input.txt");
if(!myfile)
{
cout<<"Cannot open file."<<endl;
return 1;
}
for(int row = 0; row < numRows; row++)
{
for(int col = 0; col <numColumns; col++)
{
myfile>>hands[row][col];
cout<< hands[row][col] << " ";
}
cout<<endl;
}
myfile.close();
//find the triplet
for(int row = 0; row < numRows; row++)
{
for(int col = 0; col <numColumns; col++)
{
hands[row][col] = "A";
}
}
system("PAUSE");
return 0;
}