• Welcome to Valhalla Legends Archive.
 

asdfgh

Started by Naem, October 13, 2004, 01:34 PM

Previous topic - Next topic

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] == 0)
        {
          chessbrd[row]=1;
          esize++;
        }//end if
        else
          chessbrd[row]=1;
      }//end of for loop
      for (int i=0;i<4;i++)
      {
        if (chessbrd[column]==0)
        {
          chessbrd[column]=1;
          esize++;
        }//end if
        else
          chessbrd[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] == 0)
        {
          BOARD[ROW]=1;
          COUNT++;
        }//end if
        else
          BOARD[ROW]=1;
      }//end of for loop
      for (int i=0;i<4;i++)
      {
        if (BOARD[COLUMN]==0)
        {
          BOARD[COLUMN]=1;
          COUNT++;
        }//end if
        else
          BOARD[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[j]);
    }
  }


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

}//end of main func

اگر بتوانید این را بهخوابید ، من را "پی ام" کنید

K

Why are you using cout and printf?  Why do you include stdlib and iomanip if you don't use anything from them?

Yoni

Quote from: Naem on October 13, 2004, 01:34 PM
The Queen's movements include moving in a straight line at any 44 degree angle
I think that's cheating.

Newby

Quote from: K on October 13, 2004, 06:47 PM
Why are you using cout and printf?  Why do you include stdlib and iomanip if you don't use anything from them?
Because he can.
- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

K

Quote from: Newby on October 13, 2004, 09:52 PM
Quote from: K on October 13, 2004, 06:47 PM
Why are you using cout and printf? Why do you include stdlib and iomanip if you don't use anything from them?
Because he can.

touché

Naem

Quote from: K on October 13, 2004, 06:47 PM
Why are you using cout and printf?

why not

Quote from: K on October 13, 2004, 06:47 PMWhy do you include stdlib and iomanip if you don't use anything from them?

Not yet.....

اگر بتوانید این را بهخوابید ، من را "پی ام" کنید

Yoni

Quote from: Naem on October 14, 2004, 02:44 PM
Quote from: K on October 13, 2004, 06:47 PM
Why are you using cout and printf?

why not


Generally bad idea to mix them. Unexpected results may ensue. Pick one and stick with it.