Mid-Atlantic S2000 Owners Members from Maryland, DC and Virginia

Computer Science Cheat Sheet

Thread Tools
 
Old May 3, 2004 | 09:12 PM
  #1  
C45P312's Avatar
Thread Starter
Registered User
 
Joined: Dec 2003
Posts: 7,271
Likes: 0
From: Virginia Beach
Default Computer Science Cheat Sheet



#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
string input;
char asc1, asc2, asc;
int cols;

cout<<"Input any two ASCII characters from the keyboard"<<endl;
cout<<"Example: d and k and 3"<<endl<<endl;
getline(cin,input);
cout<<endl;

cout<<"input:"<<input<<endl<<endl;

asc1 = input[0];
asc2 = input[6];
cols = input[12]- 48;

cout<<asc1<<" "<<asc2<<" "<<cols<<endl<<endl;

asc = asc1;

while (asc != asc2+1)
{
for(int count = 0; count < cols; count++)
{
cout<<asc<<" ";
asc++;
if(asc==asc2+1)
count=1000;
}

cout<<endl<<endl;
}

system("PAUSE");
return 0;
}
Reply
Old May 3, 2004 | 09:12 PM
  #2  
C45P312's Avatar
Thread Starter
Registered User
 
Joined: Dec 2003
Posts: 7,271
Likes: 0
From: Virginia Beach
Default

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

int main()
{
char board[3][3];
int row, col;

cout<<"First move in TIC-TAC-TOE"<<endl<<endl;


for(row=0; row<3; row++)
{
for(col=0; col<3; col++)
board[row][col] = '_';
}

for(int row=0; row<3; row++)
{ cout<<setw(20);
for(int col=0; col<3; col++)
{
cout<<" "<<board[row][col];
}
cout<<endl<<endl;
}
cout<<endl<<endl;

cout<<"What row and column to place 'X' in?"<<endl;
cout<<"row: ";
cin>>row;
cout<<"col: ";
cin>>col;


system("CLS");
cout<<endl<<endl;

board[row-1][col-1] = 'X';

for(int row=0; row<3; row++)
{
cout<<setw(20);
for(int col=0; col<3; col++)
{
cout<<" "<<board[row][col];
}
cout<<endl<<endl;
}
cout<<endl<<endl;


cout<<endl<<endl;

system("PAUSE");
return 0;
}
Reply
Old May 3, 2004 | 09:14 PM
  #3  
C45P312's Avatar
Thread Starter
Registered User
 
Joined: Dec 2003
Posts: 7,271
Likes: 0
From: Virginia Beach
Default

#include <iostream>
#include <string>

using namespace std;

int main()
{
string message;
char choice;

do
{
cout<<" Message Manipulation Menu"<<endl;
cout<<" a) Add to the message"<<endl;
cout<<" b) Erase message and start all over"<<endl;
cout<<" c) Display current message"<<endl;
cout<<" q) Quit "<<endl<<endl<<"Choice:";
cin>>choice;
cin.ignore();

system("CLS");

switch(choice)
{

case 'a': { string new_message;
cout<<"Enter in message to add: ";
getline(cin,new_message);
message += " ";
message += new_message;break;}

case 'b': {message = " ";
cout<<"Message erased"<<endl<<endl; system("PAUSE");break;}
case 'c': {cout<<"Current message: "<<message<<endl<<endl;system("PAUSE");break;}
case 'q': {cout<<"GAME OVER"<<endl<<endl;system("PAUSE");
return 0;break;}

}

system("CLS");
}while(choice != 'q');

}
Reply
Old May 3, 2004 | 09:30 PM
  #4  
brerspidur's Avatar
Registered User
 
Joined: Nov 2002
Posts: 4,579
Likes: 0
From: richmond
Default

wow, i used to know what that stuf meant, . . . .maybe that was when i was sober, . . ill try again tomorrow
Reply
Old May 3, 2004 | 09:31 PM
  #5  
brerspidur's Avatar
Registered User
 
Joined: Nov 2002
Posts: 4,579
Likes: 0
From: richmond
Default

damn c++
Reply
Old May 3, 2004 | 09:33 PM
  #6  
wwwracer's Avatar
Registered User
Gold Member (Premium)
 
Joined: Mar 2004
Posts: 2,139
Likes: 1
From: Pacific Palisades
Default

what's up with all windows c++? I think I noticed
a few syntax errors
Reply
Old May 4, 2004 | 03:48 AM
  #7  
C45P312's Avatar
Thread Starter
Registered User
 
Joined: Dec 2003
Posts: 7,271
Likes: 0
From: Virginia Beach
Default

[QUOTE]Originally posted by itryan
what's up with all windows c++?
Reply
Old May 4, 2004 | 03:52 AM
  #8  
StreetDreamzS2K's Avatar
Registered User
 
Joined: Jan 2003
Posts: 380
Likes: 0
From: Burtonsville
Default

Holy sh*t....i will stick to installing security systems...
Reply
Old May 4, 2004 | 04:05 AM
  #9  
sweetj's Avatar
Gold Member (Premium)
20 Year Member
Liked
 
Joined: Mar 2001
Posts: 34,298
Likes: 2
From: Baltimore, MD
Default

Carlo,

are you sure this is ok.....
Reply
Old May 4, 2004 | 04:05 AM
  #10  
C45P312's Avatar
Thread Starter
Registered User
 
Joined: Dec 2003
Posts: 7,271
Likes: 0
From: Virginia Beach
Default

Originally posted by StreetDreamzS2K
Holy sh*t....i will stick to installing security systems...
Reply



All times are GMT -8. The time now is 05:04 AM.