BTC USD 85,634.7 Gold USD 4,309.82
Time now: Jun 1, 12:00 AM

Sapa reti C++ sini?

haa.. flowchart. lupe plak mende tuh. bak mai flowchart la senang nak wat kerje.
 
Code:
#include <inpout.h>

void main()
{
int p,g;
char c;

cout<<"How many points would you like?";
cin>>p;


cout<<"Guesses Choices"<<br
<<"O Odd"<<br
<<"E Even"<<br
<<"L Low"<<br
<<"M Med"<<br
<<"H High"<<br
<<"F Left"<<br
<<"C Center"<<br
<<"R Right"<<br
<<"N Number";

cout<<"How many guesses would you like?";
cin>>g;

if(int i= 0; i =< g; i++)

cout<<"Guess "<<i<<endl;

cout<<"Enter your choice :";
cin>>c;

if (c == 'L')||(c == 'l')

.
.
.
.
.
Math part

Aku skip math part. tak brape paham ape dia nak. hehe. btw, ni boleh dijadikan idea n permulaan. aku takde software C++. aku pakai notepad jek ni. tak compile lagi. tgk la kalo ade error ke. ade byk cara nak tulis prog ni. ni cara paling simple la kot. :D

Tgok code ni macam ok dah ni. Cuma part math je kena edit. Mana sajul ni x masuk sini lg, kang aku suh dia tengokkan..
 
macam nak tolong, tapi :

1. aku tak ada compiler, kalau ada pun compiler C untuk mikroprosesor Atmel.
2. Buat la sendiri, tak buat macam mana nak pandai.
 
Tgok code ni macam ok dah ni. Cuma part math je kena edit. Mana sajul ni x masuk sini lg, kang aku suh dia tengokkan..

yg tu biase jek tu. same level macam buat "Hello World" jek tuh. Ade flowchart bole kasi bikin sampai abes. Tapi aku dok pikir pogram yg asal ni macam kelakar la. ade yg xkene ngan pogram tu. ade defect kot.
 
Last edited:
erk...rapid boleh buat...tapi formula apa nak guna?dan >>br?mewakili variable apa?
 
Abg_x pun boleh gak C++ ni... tapi lagi terrer Visual Basic, LabVIEW pun ok gak.. kalau Fortran, kurang sket dari C++ la..
 
Code:
#include <cstdlib>
#include <iostream>

struct game
{
int guess;	
char type;	
int number;	
int amount;	
int WinLose;
};


using namespace std;

int main()
{   
    int data[12][3];
    int a = 1;
    int point, n, x=5;
    int Risk[9] = {0};
    int TotalPoint = 0;
    char choices, k;
    
    cout<< " |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|\n";
    cout<< " |                               Guessing Game                                |\n";
    cout<< " |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|\n\n";
    
   

    void GameStart(int[][3], int[], int, int);
    
    for(int i=0; i < 12; i++)
            for(int j=0; j<3; j++)
                    data[i][j]=a++;   


//----game start...
           do
           {
           cout << "How many point would u like? ";
           cin >> point;
           cout << endl;
           
           cout << "How many guesses would you like? ";
           cin >> n;
           cout << endl;
           
           cout << "Below are the choices you can choose." << endl;
           cout << "Please select the choices you want.\n" << endl;
           
           cout<< "Guesses Choices"<<endl;
           cout<< "   O    Odd"<<endl;
           cout<< "   E    Even"<<endl;
           cout<< "   L    Low"<<endl;
           cout<< "   M    Med"<<endl;
           cout<< "   H    High"<<endl;
           cout<< "   F    Left"<<endl;
           cout<< "   C    Center"<<endl;
           cout<< "   R    Right"<<endl;
           cout<< "   N    Number"<<endl<<endl;
    
           cout << "Lower number is from 1-12" <<endl;
           cout << "Medium number is from 13-24" <<endl;
           cout << "High number is from 25-36" <<endl;
           cout << "The specific number is from 1-36 only" << endl;

    
    GameStart(data, Risk, n, x);

    for(int i = 0; i < 9; i++)
     TotalPoint = TotalPoint + Risk[i];    

     cout << "My Number is " << x << endl;
     cout << "Previous Points: " << point << endl;
     cout << "You won " << TotalPoint << " points in this turn." << endl;
     cout << "Your new balance is: "<< point + TotalPoint << " points." << endl<< endl;
     cout << "Do you want to continue???[y/n]" ;
     cin >> k;
     cout << endl << endl;
     }
     while (k=='y' || k=='Y');
     
//cout<<"Guess"<<"Type"<<"Number"<<"Amount"<<"Win or Lose";

//	Do you want to play again (Y or NO)? Y

  
    system("pause");
    
    return 0;

}




void GameStart(int data[][3],int Risk[],int n,int x)
{
  int risk, a;
  char choices, temp;
  int number;
  for(int y=1; y<=n; y++)   
   {
          risk =0;
          cout<<"Guess "<< y <<" : \n";
          
          cout<<"Enter your choices: ";
          cin>>choices;
          
          if(choices == 'n' || choices == 'N')
          {
                     cout<<"Enter your number : ";
                     cin>>number;
                     cout << endl;
          }
   
          cout << "Points at risk : ";
          cin >> risk;
          cout << endl;
       
   
   switch(choices)
   {
    case 'o':
    case 'O':
         if(x % 2 != 0)
             Risk[0] = Risk[0] + risk * 1;
         else
             Risk[0] = Risk[0] + risk * -1;
         break;
         
    case 'e':
    case 'E':
         if(x % 2 == 0)
           Risk[1] = Risk[1] + risk * 1;
         else
           Risk[1] = Risk[1] + risk * -1;
         break;
         
    case 'l':
    case 'L':
         if(x < 13)
           Risk[2] = Risk[2] + risk * 2;
         else
           Risk[2] = Risk[2] + risk * -1;
         break;
         
    case 'm':
    case 'M':
         if(x > 12 && x < 25)
           Risk[3] = Risk[3] + risk * 2;
         else
           Risk[3] = Risk[3] + risk * -1;
         break;
         
    case 'h':
    case 'H':
         if(x > 24)
           Risk[4] = Risk[4] + risk * 2;
         else
           Risk[4] = Risk[4] + risk * -1;
         break;
//--------------------------------------
    case 'f':
    case 'F':
        for(int a = 0; a < 12; a++)
          if(x == data[a][0])
            {
                  temp = 'y';
                  break;
            }         
          else
             temp = 'n';   
           
           if(temp == 'y')
            Risk[5] = Risk[5] + risk * 2;
           else
            Risk[5] = Risk[5] + risk * -1;
         break;
    case 'c':
    case 'C':
       for(int a = 0; a < 12; a++)
          if(x == data[a][1])
            {
                  temp = 'y';
                  break;
             }         
          else
             temp = 'n';   
           
           if(temp == 'y')
            Risk[6] = Risk[6] + risk * 2;
           else
            Risk[6] = Risk[6] + risk * -1;
         break;
    case 'r':
    case 'R':
       for(int a = 0; a < 12; a++)
          if(x == data[a][2])
            {
                  temp = 'y';
                  break;
             }         
          else
             temp = 'n';   
           
           if(temp == 'y')
            Risk[7] = Risk[7] + risk * 2;
           else
            Risk[7] = Risk[7] + risk * -1;
         break;
//--------------------------------------------------
    case 'n':
    case 'N':
         
         if(number == x)
          Risk[8] = Risk[8] + risk * 36;
         else
          Risk[8] = Risk[8] + risk * -1; 
         break;
    default: 
             cout<<"Sorry!!! You have key in a wrong input."<<endl;
             cout << "Please enter again!!!"<<endl;
             break;
      }     
      }
      }


Ni dia coding sepenuhnya..akhirnya berjaya jg aku wat.. :D
 
hahaha... cantik la pogram ko.

br tu macam enter la.
 
Ni untuk software ke website? Kalau website pakai php jer dah boleh kann?
 
Back
Top
Log in Register