Valhalla Legends Forums Archive | Testing Forum | asdfgh

AuthorMessageTime
Naem
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <windows.h>

using namespace std;

int menu();
int wheretogo();

int main()
{
  int menuselect;
  menuselect = menu();
  return 0;
}

int menu()
{
  int menuselect;
  do
  {
    cout << "0) Insert Name\n";
    cout << "1) Sort Names\n";
    cout << "2) Switch First and Last Names\n";
    cout << "3) Display All Names\n";
    cout << "4) Start Over\n";
    cout << "5) Quit\n\n";
    cout << "Selection: ";
    cin >> menuselect;
    if (menuselect < 0 || menuselect > 5)
    {
      cout << "Please enter a valid menu option.\n";
      Sleep(5000);
    }
  }
  while (menuselect < 0 || menuselect > 5);
  return menuselect;
}

void wheretogo()
{
  int menuselect;
  menuselect = menu();
  switch (functions)
  {
  case 0:
    insertname();
    break;
  case 1:
    sortnames();
    break;
  case 2:
    switchnames();
    break;
  case 3:
    displaynames();
    break;
  case 4:
    startover();
    break;
  case 5:
    quit();
    break;
  default:
    cout << "oh em gee u r h4x0r"; //should not happen
    break;
  } // end of switch
} // end of function wheretogo()










#include <stdlib.h>
#include <stdio.h>
#include <iostream>

#define CHESSBRDSIZE 4*4 //Board's size = 4x4 = 16

using namespace std;

/*************************************************************************************
This "Queens" program is designed to emulate a four by four chess chessbrd occupying
queens that can move in any 45 degree angle, with the rule that no queen may be in
another queen's path. Created Oct. 15.
*************************************************************************************/
int main()
{
  static int chessbrd[4][4]={};//Chess Board
  static int esize=0; //Effective Size
  do
  {
    int row = rand()%4;
    int column = rand()%4;
    if (chessbrd[row][column] != 1 && chessbrd[row][column] != 5)
    {
      for (int i=0;i<4;i++)
      {
        if (chessbrd[row][i] == 0)
        {
          chessbrd[row][i]=1;
          esize++;
        }//end if
        else
          chessbrd[row][i]=1;
      }//end of for loop
      for (int i=0;i<4;i++)
      {
        if (chessbrd[i][column]==0)
        {
          chessbrd[i][column]=1;
          esize++;
        }//end if
        else
          chessbrd[i][column]=1;
      }//end of for loop
      for (int i=0;i<4;i++)
      {
        if (chessbrd[row-i][column-i]==0)
        {
          chessbrd[row-i][column-i] = 1;
          esize++;
        }//end if
        else
          chessbrd[row-i][column-i]=1;
      }//end of for loop
      for (int i=0;i<4;i++)
      {
        if (chessbrd[row+i][column+i]==0)
        {
          chessbrd[row+i][column+i] = 1;
          esize++;
        }//end if
        else
          chessbrd[row+i][column+i];
      }//end of for loop
      chessbrd[row][column] = 5;
      esize++;
    }
  }
 
  while (esize<=CHESSBRDSIZE);

  //Display Board
  for (int r=0;r<4;r++)
  {
    cout << "\n\n"; //Spaces between rows for readability purposes
    for (int c=0;c<4;c++)
    {
      if (chessbrd[r][c] == 1)
        cout << ".  ";
      if (chessbrd[r][c] == 5)
        cout << "Q  ";
      if (chessbrd[r][c] == 0)
        cout << "Q  ";
      /*Above code translates array entries
        into more readable ascii text.   */
    }
  }
  cout << "\n\n\n\n";
  return 0; // return 0 for main
}           // end of main














#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

#define TOTAL 16 //total size of board
/*************************************************************************************
**  This executable's purpose is to use up a double array based on the movement of  **
**  the chess peice known as the 'Queen'.  The Queen's movements include moving     **
**  in a straight line at any 44 degree angle (i.e. Forward, Diagonally, etc.)      **
**                                                                                  ** 
**  Created : Tuesday, October 12, 2004                                             **
**                                                                                  **
**  Notes : For some strange reason, the code stops working if you enlarge the size **
**          any more.  Will inquire about this soon to Sabzevari.                   **
*************************************************************************************/
void main()
{
  static int COUNT=0; //Keeps running track of the number of used cells
  static int BOARD[4][4]={};//The "Board"
  do
  {
    int ROW = rand()%4;
    int COLUMN = rand()%4;
    if (BOARD[ROW][COLUMN] != 1 && BOARD[ROW][COLUMN] != 5)
    {
      for (int i=0;i<4;i++)
      {
        if (BOARD[ROW][i] == 0)
        {
          BOARD[ROW][i]=1;
          COUNT++;
        }//end if
        else
          BOARD[ROW][i]=1;
      }//end of for loop
      for (int i=0;i<4;i++)
      {
        if (BOARD[i][COLUMN]==0)
        {
          BOARD[i][COLUMN]=1;
          COUNT++;
        }//end if
        else
          BOARD[i][COLUMN]=1;
      }//end of for loop
      for (int i=0;i<4;i++)
      {
        if (BOARD[ROW-i][COLUMN-i]==0)
        {
          BOARD[ROW-i][COLUMN-i] = 1;
          COUNT++;
        }//end if
        else
          BOARD[ROW-i][COLUMN-i]=1;
      }//end of for loop
      for (int i=0;i<4;i++)
      {
        if (BOARD[ROW+i][COLUMN+i]==0)
        {
          BOARD[ROW+i][COLUMN+i] = 1;
          COUNT++;
        }//end if
        else
          BOARD[ROW+i][COLUMN+i];
      }//end of for loop
      BOARD[ROW][COLUMN] = 5;
    }
  }
  while (COUNT<=TOTAL);



  //code below this line is for printing out to check.//
  //**************************************************//
  //**************************************************//
  for (int i=0;i<4;i++)
  {
    cout<<endl<<endl;
    for (int j=0;j<4;j++)
    {
      printf("%d  ",BOARD[i][j]);
    }
  }


  cout<<endl<<endl<<endl<<endl;

}//end of main func

October 13, 2004, 6:34 PM
K
Why are you using cout and printf?  Why do you include stdlib and iomanip if you don't use anything from them?
October 13, 2004, 11:47 PM
Yoni
[quote author=Naem link=topic=9138.msg84229#msg84229 date=1097692452]
The Queen's movements include moving in a straight line at any 44 degree angle
[/quote]
I think that's cheating.
October 14, 2004, 12:09 AM
Newby
[quote author=K link=topic=9138.msg84286#msg84286 date=1097711224]
Why are you using cout and printf?  Why do you include stdlib and iomanip if you don't use anything from them?
[/quote]
Because he can.
October 14, 2004, 2:52 AM
K
[quote author=Newby link=topic=9138.msg84316#msg84316 date=1097722325]
[quote author=K link=topic=9138.msg84286#msg84286 date=1097711224]
Why are you using cout and printf? Why do you include stdlib and iomanip if you don't use anything from them?
[/quote]
Because he can.
[/quote]

touché
October 14, 2004, 5:00 AM
Naem
[quote author=K link=topic=9138.msg84286#msg84286 date=1097711224]
Why are you using cout and printf?
[/quote]

why not

[quote author=K link=topic=9138.msg84286#msg84286 date=1097711224] Why do you include stdlib and iomanip if you don't use anything from them?[/quote]

Not yet.....

October 14, 2004, 7:44 PM
Yoni
[quote author=Naem link=topic=9138.msg84405#msg84405 date=1097783076]
[quote author=K link=topic=9138.msg84286#msg84286 date=1097711224]
Why are you using cout and printf?
[/quote]

why not

[/quote]

Generally bad idea to mix them. Unexpected results may ensue. Pick one and stick with it.
October 14, 2004, 8:12 PM

Search