Thursday, December 15, 2011

PICS IN SDA


                                                            XMAS DESIGN IN SDA

Wednesday, December 14, 2011

Microsoft Visual Studios

-----------> MICROSOFT VISUAL STDIOS

Microsoft Visual Studios

Codes for Quest

#include
#include
#include

void main()
{
int N = 0;
printf("Enter Value:");
scanf("%i", &N);
int sum = 0, num = 1;
for(int N1 = 0; N1 <= N; N1++)
{
num==N1;
sum+=num;
printf("%i", num);
}
printf("\nSum is: %i", sum);
getch();
return;
}
--------------0--------------------------------
#include
#include
#include

void main()
{
int let;
bool ter=true;
while(true)
{
if(ter)
{
let=65;
}
else
{
let=97;
}
printf("Random letter = %c\n",(rand()%26)+let);
ter=rand()%2;
getch();
}

printf("\n\nGame Over!");
getch();
return;
}
--------------0----------------------
#include
#include
#include

#include
#include

#include
#include

using namespace std;

void main()
//{
// int x = 0;
// int y = 0;
// int z = 1;
// while (x < 5)
// {
// int y = 0;
// while (y < z)
// {
// printf("*");
// y++;
// }
// printf("\n");
// x++;
// z++;
// }
//
//getch();
//return;
//}

/* ======BORDER===== */

//{
//char Num = '0';
//
//bool ValidNumber = false;
//
//while (!ValidNumber)
//
// {
// printf("Enter 0-9: ");
// scanf(" %c", &Num);
//
// if (Num>='0' && Num<='9')
// {
// printf("Valid number!");
// ValidNumber = true;
// }
// }
//printf("\n\nGame Over!");
//getch();
//return;
//}

/* ======BORDER===== */
// Limited to a maximum of 3 "while" statements

//{
// int con1 = 0;
// int con2 = 0;
// int con3 = 4;
// int con4 = 0;
// int con5 = 0;
// while (con1 < 5)
// {
// int con2 = 0;
// while (con2 < con3)
// {
// printf("_");
// con2++;
// }
// {
// printf("*");
// con1++;
// con3--;
// }
// /*while (con3 < con1)
// {
// printf("+");
// con3++;
// }*/
// printf("\n");
// }
//
//getch();
//return;
//}

/* ======BORDER===== */

//{
// for (int i1=0; i1<5; i1++)
// {
// for (int i2=0; i2<10; i2++)
// {
// printf("*");
// }
// printf("\n");
// }
// getch();
// return;
//}

/* ======BORDER===== */

//{
// for (int con1=0, con3=4; con1<5; con1++, con3--)
// {
// for (int con2=0; con2
// {
// printf(" ");
// }
// for (int con3=-1; con3
// {
// printf("*");
// }
// printf("\n");
// }
// getch();
// return;
//}

///* ======BORDER===== */
//
// srand(time(NULL));
//
// int Number = ((rand() % 10)) % 4;
// while (Number % 4 != 0)
// {
// Number = ((rand() % 10) + 1);
// printf("Game Over!\n");
// }
// printf("\nNumber = %d", Number);
//
// printf("\n\nGame Over!");
// getch();
// return;
//}

///* ======BORDER===== */
//{
// int x = 0;
// {
// while (true)
// {
// if ( x >= 0 && x <= 90 && x >= 97 && x <= 122 )
// //((rand() % 26) + (65 || 97));
// printf("Random Number = %d\n", (rand() % 26) + 65);
// getch();
// }
// }
// printf("\n\nGame Over!");
// getch();
// return;
//}

///* ======BORDER===== */

//{
// int i = 0;
// int j = 0;
// printf("Enter i > 2: ");
// scanf("%i", &i);
// printf("Enter j > 2: ");
// scanf("%i", &j);
// for(int Numi=0; Numi
// {
// for(int Numj=0; Numj
// if((Numj == 0 || Numj == j-1)
// && (Numi == 0 || Numi == i-1))
// printf(" ");
//
// //if(Numj < 2 && Numi < 2);
//
// else
// printf("*");
//
// printf("\n");
// }
// getch();
// return;
//}

///* ======BORDER===== */

//{
// int N = 0;
// int Sum = 1;
// printf("Enter N: ");
// scanf("%i", &N);
// for (int x = 1; x <= N; x++)
// {
// Sum = Sum + x;
// for (int y = 0; y < Sum; y++)
// printf("*");
// printf("\n");
// }
// printf("Summation = %i", Sum);
//
// printf("\n\nGame Over!");
// getch();
// return;
//}

/*int test;
int sum;
printf("Enter: ");
scanf("%i", &test);
for(int x = 0, x
x++;*/

///* ======BORDER===== */

/* Already at top */
//#include
//#include
//#include
//
//#include
//#include
//
//void main()

//{
// int x = 1;
// {
// while (true)
// {
// if(rand() % 2 < 1)
// printf("Random Number = %c\n", (rand() % 26) + 97);
// else
// printf("Random Number = %c\n", (rand() % 26) + 65);
// getch();
// }
// }
// printf("\n\nGame Over!");
// getch();
// return;
//}

///* ======BORDER===== */

/* added to top ^ */
// #include
// #include
//
// use namespace std;

//{
/* Arrays */

/* Part 1 of Arrays
// {
Number order: 0 1 2 3 4 5
char Name[7] = {'S', 'i', 'l', 'v', 'e', 'r'};
printf("My name is %s\n", Name);
printf("%c\n", Name[1]);

int Numbers[10];
for (int i = 0; i < 10; i++)
Numbers[i] = -1;

// display all the elements of Numbers
for (int i = 0; i <10; i++)
printf("Number[%d] = %d\n", i , Numbers[i]);

float Red[4] = {1.0, 0.0, 0.0, 0.0};
}
*/

/* Part 2 of Arrays */

/* Strings */

/*char word1[6] = {'H', 'e', 'l', 'l', 'o'};
string Word1 = "Hello";
cout << Word1 << "\n";
printf("%c\n", Word1[1]);
printf("Word1 length = %d\n", Word1.size());

string Word2 = "World";

string Phrase = Word1 + " " + Word2;
cout << "Phrase = " << Phrase << "\n";*/

//// Display each character of Phrase, per line
// /* The simple and "dirty" method */
// cout << word1[0] << "\n" << word1[1] << "\n" << word1[2] << "\n" << word1[3] << "\n" << word1[4] << "\n";
//
// /* The better and shorter method */
// for (int i = 0; i < Phrase.size(); i++)
// //cout << Phrase[i] << "\n";
// /* Shows the number/position of the letters of "Hello World" */
// printf("Character at position %d = %c\n", i, Phrase[i]);
//
// printf("\nW is at position = %d\n", Phrase.find("W"));
// printf("\nX is at position = %d\n", Phrase.find("X"));
//
// /* "Phrase.erase" removes the selected character, and the number after it determines how many is removed (ex. "Phrase.erase(6, 1);"), if none (ex. "Phrase.erase(6);") then it removes everything */
// Phrase.erase(6, 1);
// cout << "Phrase = " << Phrase << "\n";
//
// /* ".erase();" */
// Phrase.erase();
// //Phrase.erase(2);
// cout << "Phrase = " << Phrase << "\n";
// if (Phrase.empty())
// {
// printf("\nPhrase is empty!");
// }
// else
// {
// printf("\nThere are cookies in my jar!");
// }
//
// /* Requires "const" */
// //int MaxItems = 10;
// const int MaxItems = 10;
// string Inventory[MaxItems];
//
// int NumItems = 0;
// Inventory[NumItems++] = "sword"; // i++ vs ++i
// Inventory[NumItems++] = "armor";
// Inventory[NumItems++] = "shield";
//
//// display the contents of our inventory
// printf("Your inventory items:\n");
// for (int i = 0; i < MaxItems; i++)
// cout << Inventory[i] << endl;
//
//// how many items do we have in our inventory? 3
//
// char Replace;
// string NewWeapon = "Axe";
// cout << "Picked up an " << NewWeapon << endl;
// printf("Do you want to replace your sword?");
// scanf("%c", &Replace);
// if (Replace == 'y')
// Inventory[0] = NewWeapon;
//
//// display the contents of our inventory
// printf("Your inventory items:\n");
// for (int i = 0; i < MaxItems; i++)
// cout << Inventory[i] << endl;
//
// printf("\n\nGame Over!");
// getch();
// return;
//}

///* ======BORDER===== */

/* NOTE: void main() already exists up top ^ */
// void main()
{
string Name;
string Class;
int Stats[3];
char Choice;

/* Foot Note: "for" loop will always know how many times it would repeat, "while" loop may not, which makes it the common difference between the two */

bool Done = false;
while (!Done)
{
printf("Change [N]ame\n");
printf("Change [C]lass\n");
printf("Change [S]tats\n");
printf("D[o]ne\n");
//scanf("%c", &Choice); - Replaced with cin, which is similar
cin >> Choice;
if(Choice == 'n' || Choice == 'N')
{
/* cout ("C-out") is similar to printf, except cout prints "strings" */
cout << "Current Name: " << Name << endl;
printf("Enter name: ");
/* cin ("C-in") is the equivalent of scanf, for strings */
cin >> Name;
cout << "New Name: " << Name << endl;
}

if(Choice == 'c' || Choice == 'C')
{
char iClass;
iClass = 0;
cout << "Current Class: " << Class << endl;
while (iClass < '1' || iClass > '4')
{
printf("1 - Warrior\n");
printf("2 - Priest\n");
printf("3 - Warlock\n");
printf("4 - Mage\n");
cin >> iClass;
}
switch (iClass)
{
case '1':
Class = "Warrior";
break;
case '2':
Class = "Priest";
break;
case '3':
Class = "Warlock";
break;
case '4':
Class = "Mage";
break;
}
cout << "New Class: " << Class << endl;
}
if(Choice == 's' || Choice == 'S')
{
int PointsLeft = 5;
Stats[0] = 0;
Stats[1] = 0;
Stats[2] = 0;
for (int i = 0; i < 5; i++)
{
printf("Points Left: %d\n", PointsLeft - i);
printf("\n");
printf("1 - Intelligence: %d\n", Stats[0]);
printf("2 - Dexterity: %d\n", Stats[1]);
printf("3 - Strength: %d\n", Stats[2]);
char iStats = 0;
cin >> iStats;
switch (iStats)
{
case '1':
Stats[0]++;
break;
case '2':
Stats[1]++;
break;
case '3':
Stats[2]++;
break;
//cout << "Points Left: " << PointsLeft << endl;
}
}
printf("\n\nNew Stats\n");
printf("1 - Intelligence: %d\n", Stats[0]);
printf("2 - Dexterity: %d\n", Stats[1]);
printf("3 - Strength: %d\n", Stats[2]);
}

if(Choice == 'o' || Choice == 'O')
{
cout << endl << "Player Name: " << Name << endl;
cout << "Player Class: " << Class << endl;
cout << "Player Stats " << endl;
cout << "Intelligence - " << Stats[0] << endl;
cout << "Dexterity - " << Stats[1] << endl;
cout << "Strength - " << Stats[2] << endl;
//cout << "Points Remaining: " << PointsLeft << endl;
Done = true;
}

printf("\n");
}

printf("\n\nGame Over!");
getch();
return;
}
------------------------0----------------------
#include
#include
#include

using namespace std;

int main(int argc, char *argv[])
{
long Secret = 0, User = 0;
const long max = 100, min = 1;
int play = 0, guesses = 3;

while (true)
{
printf( "1. Play\n2. Exit\n>");
cin >> play;
if (play == 2) { return(0); }
if (play != 1) { cout << "Not a valid choice!\n\n"; continue; }

srand(time(NULL));
Secret = (rand() % (max - min + 1)) + min;
guesses = 0;

printf( "\nGuess My Number %i to %i\n\n>", min, max);

while (Secret != User && guesses < 3)
{
cin >> User;
guesses++;

if (Secret > User) {cout << "Higher\n\n>";}
else if (Secret < User) {cout << "Lower\n\n>";}
}
cout << "The number is "<< Secret << endl << "Game over " << guesses << " tries." << endl << endl;
}


system("PAUSE");
return EXIT_SUCCESS;
}