#define max_items 50
typedef int itemtype;
#include<iostream>
#include<string>
#include<math.h>
#include<fstream>
using namespace std;
class posteval
{
private:
string input;
itemtype result;
int top;
itemtype *items;
int cheak;
int counter;
public:
posteval();
void getexp();
void display();
bool isfull();
bool isempty();
void push(itemtype x);
itemtype pop();
void eval();
void cheakexp();
};
posteval::posteval()
{
top=-1;
items=new itemtype[max_items];
input=" ";
result=0;
cheak=0;
counter=0;
}
void posteval::getexp()
{
ifstream myfile("test.txt");
myfile>>input;
}
void posteval::display()
{
cout<<"\nThe resultant of the given postfix expression is : "<<result<<endl;
}
bool posteval::isfull()
{
if (top==max_items)
{
return 1;
}
else
{
return 0;
}
}
bool posteval::isempty()
{
if (top==-1)
{
return 1;
}
else
{
return 0;
}
}
void posteval::push(itemtype x)
{
if(isfull())
{
cout<<"\nStack Overflow";
exit(1);
}
else
{
top++;
items[top]=x;
}
}
itemtype posteval::pop()
{
itemtype z;
if(isempty())
{
cout<<"\nStack Underflow";
exit(1);
}
else
{
z=items[top];
top--;
return z;
}
}
void posteval::eval()
{
char exp;
itemtype operand1;
itemtype operand2;
exp=input[cheak];
while(cheak<input.length())
{
if(exp=='0'||exp=='1'||exp=='2'||exp=='3'||exp=='4'||exp=='5'||exp=='6'||exp=='7'||exp=='8'||exp=='9')
{
int x;
x=exp-48;
push(x);
}
else
{
operand2=pop();
operand1=pop();
if(exp=='+')
{
result=operand1+operand2;
}
else if(exp=='-')
{
result=operand1-operand2;
}
else if(exp=='*')
{
result=operand1*operand2;
}
else if(exp=='/')
{
result=operand1/operand2;
}
else if(exp=='$')
{
result=pow(operand1,operand2);
}
push(result);
}
cheak++;
exp=input[cheak];
}
if(!isempty())
{
result=pop();
}
}
void posteval::cheakexp()
{
for (int i=0;i<input.length();i++)
{
if(input[i]=='0'||input[i]=='1'||input[i]=='2'||input[i]=='3'||input[i]=='4'||input[i]=='5'||input[i]=='6'||input[i]=='7'||input[i]=='8'||input[i]=='9')
{
counter++;
}
else
{
counter-=1;
}
}
if(counter==1)
{
posteval::eval();
posteval::display();
}
else
{
cout<<"\nExpression is invalid\n";
}
}
void main()
{
posteval ob;
ob.getexp();
ob.cheakexp();
}
Thursday, 11 July 2013
Postfix Evaluation
Minesweeper Game in C++
#include<iostream>
#include <stdlib.h>
#include<conio.h>
using namespace std;
void main()
{
int option;
int counter=0;
cout<<"for easy enter 1, for hard enter 2: ";
cin>>option;
cout<<endl;
while(option!=1&&option!=2)
{
cout<<"enter 1 or 2: ";
cin>>option;
cout<<endl;
}
int mainArray[10][10]; //main array which has the values
if(option==1)
{
srand(time(0));
for(int i=0;i<10;i++)
{
for(int j=0;j<10;j++)
{mainArray[i][j]=0 + rand()% 7;}
}
}
if(option==2)
{
srand(time(0));
for(int d=0;d<10;d++)
{
for(int f=0;f<10;f++)
{mainArray[d][f]=0 + rand()% 4;}
}
}
char dispArray[10][10]; //array to be displayed
for(int k=0;k<10;k++)
{ cout<<endl;
for(int l=0;l<10;l++)
{
dispArray[k][l]='*';
cout<<dispArray[k][l]<<" ";
}
}
int row;
int column;
do{
cout<<endl;
cout<<"\nEnter Row number (0 to 9): ";
cin>>row;
cout<<"Enter Column number (0 to 9): ";
cin>>column;
if(mainArray[row][column]!=0)
{
counter++;
}
clrscr();
dispArray[row][column]=(char)(mainArray[row][column]+48); //int converted it into char by its ASCII code
for(int p=0;p<10;p++)
{ cout<<endl;
for(int q=0;q<10;q++)
{
cout<<dispArray[p][q]<<" ";
}
}
}
while(mainArray[row][column]!=0);
cout<<"\n\ngame over"<<endl<<"total score= "<<counter;
_getch();
}
GPa Calculator in c++
#include<iostream.h>
#include <stdlib.h>
using namespace std;
void main()
{
char number[40] ={0}; //this array use to store enrollment number
char name[40] ={0}; // this array use to store students name
float arr[9] = {0}; // this array use to store number and gpa
float gpa,s = 0; // declare variable,,"s" variable use to store credit hours of every subject
int totalcredithours=18; // total credit hours
for(int p=0;p<1;p++) // this loop depend on number of students in class
{ // start braces for loop "p"
gpa = 0;
cout<<"\t\t\tEnrollment Number:";
cin.ignore();
cin.getline(number,80,'\n');
cout<<"\t\t\tStudent Name:";
cin.ignore();
cin.getline(name,80,'\n');
for(int i=1;i<=8;i++) // this loop run only 6 times to get subject number and this loop use only in switch statement
{ // start braces for loop "i"
int x; //declare variable to get number from user
switch(i) //conditional statement
{ // start braces for switch statement
case 1:
cout<<"\n\t\t\tDiscrete Structures "<<endl;
cout<<"\t\t\tEnter Number=";
s=0+3;
break;
case 2:
cout<<"\t\t\tObject Oriented Programming"<<endl;
cout<<"\t\t\tEnter Number=";
s=0+3;
break;
case 3:
cout<<"\t\t\tCommunication Skills"<<endl;
cout<<"\t\t\tEnter Number=";
s=0+3;
break;
case 4:
cout<<"\t\t\tBasic electronics"<<endl;
cout<<"\t\t\tEnter Number=";
s=0+2;
break;
case 5:
cout<<"\t\t\tPakistan Studies"<<endl;
cout<<"\t\t\tEnter Number=";
s=0+2;
break;
case 6:
cout<<"\t\t\tscoiology"<<endl;
cout<<"\t\t\tEnter number=";
s=0+3;
break;
case 7:
cout<<"\t\t\tObject Oriented Programming lab"<<endl;
cout<<"\t\t\tEnter number=";
s=0+1;
break;
case 8:
cout<<"\t\t\tBasic electronics lab"<<endl;
cout<<"\t\t\tEnter number=";
s=0+1;
break;
default:
cout<<"\t\t\tNot Valid";
} //end braces for switch statement
cin>>x; //get numbers from user
//now we using if else statements to check grades
if(x>=87&&x<=100)
{
cout<<"\t\t\tGrade A"<<endl<<endl;
arr[i] = (4.0)*s;
}
else if(x>=79&&x<=86)
{
cout<<"\t\t\tgrade B+"<<endl<<endl;
arr[i] = (3.5)*s;
}
else if(x>=72&&x<=79)
{
cout<<"\t\t\tgrade B"<<endl<<endl;
arr[i] = (3.0)*s;
}
else if(x>=66&&x<=71)
{
cout<<"\t\t\tgrade c+"<<endl<<endl;
arr[i] = (2.5)*s;
}
else if(x>=60&&x<=65)
{
cout<<"\t\t\tgrade c"<<endl<<endl;
arr[i] = (2.0)*s;
}
else if(x>=50&&x<=59)
{
cout<<"\t\t\tgrade D"<<endl<<endl;
arr[i] = (1.5)*s;
}
else if(x<50&&x>=0)
{
cout<<"\t\t\tgrade F"<<endl<<endl;
arr[i] = (0)*s;
}
else if(x>100)
{
cout<<"\t\t\tPlease Enter Numbers '0' to '100'"<<endl<<endl;
}
if(x<0)
{
cout<<"\t\t\tPlease Enter Numbers '0' to '100'"<<endl<<endl;
}
} //end for loop "i"
float sum = 0;
for(int j=1;j<=8;j++)
{ // start braces for loop "j"
sum+= arr[j];
} // end braces for loop "j"
gpa=(sum)/totalcredithours; //formula to calculate gpa
cout<<"\t\t\tGPA="<<gpa<<endl<<endl;
if(gpa<2.0&&gpa>1.5)
{
cout<<"\t\t\tprob :(";
}
else if(gpa<1.5&&gpa>1.0)
{
cout<<"\t\t\tchance :(";
}
} //end braces for loop "p"
} //end braces main funtion
Casino + dice game in C++
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<time.h>
void rules(); //function definition
void main()
{ //start braces for main function
double balance,amount,num,dice; //declare variables
char name[50],ch; //declare variables
srand(time(0));
clrscr();
cout<<"*****************************************************************************";
cout<<"\n\n\t\t WellCome To CASINO GAME\n\n";
cout<<"*****************************************************************************";
cout<<"\n\n\t Player Name: ";
cin.getline(name,80,'\n'); // to get name from the user
cout<<"\n\n\tAccount balance:";
cin>>balance; // to get balance from the user
//starting loops and conditions
do
{ //start braces from '1' do loop
clrscr();
rules();
cout<<"\n\n\t"<<name;
cout<<"\n\n\t Your current balance is Rs:"<<balance;
cout<<"\n";
do
{ //start braces from '2' do loop
cout<<"\n\n\n\tEnter Money To Bet:";
cin>>amount; //user enter money for bet
cout<<"\n";
if(amount>balance||amount<500)
{
cout<<"\n\t Your betting amount is more than your current balance..\n";
cout<<"\n\tRe-enter your data\n ";
}
else
break;
} //end braces from '1' do loop
while(1);
do //start braces from '3' do loop
{
cout<<"\tEnter your lucky number to bet between 1 to 10 :";
cin>>num;
if(num<=1||num>10)
cout<<"\tPlease check the number!! \n\n Enter Number between 1 to 10 \n\n Re-enter data: ";
else
break;
} //end braces from '3' do loop
while(1);
dice=1+rand()%10;
if(dice==num)
{
cout<<"\n\n\n\tGood Luck!! \n\n You won Rs:";
cout<<amount*2;
balance=balance+amount*2;
}
else
{
cout<<"\n\n\n\tBad Luck this time !! \n\n";
cout<<" \tYou lose Rs:"<<amount;
balance=balance-amount;
}
cout<<"\n\n\tThe winning number was : "<<dice;
cout<<"\n\n\t"<<name;
cout<<"\t You have Rs: "<<balance<<endl;
cout<<"\n\n Do you want to play (y/n)? ";
cin>>ch;
} //end braces from '1' do loop
while(ch=='Y'|| ch=='y');
clrscr();
cout<<"\n\n\n";
cout<<"\n\n\tTHANKS FOR COME TO CASINO...\n\n YOUR BALANCE AMOUNT IS RS:"<<balance<<"\n\n";
getch();
} ////end braces for main function
void rules()
{ // start braces for function definition
clrscr();
cout<<"\n\n";
cout<<"\n\t\tRULES OF THE GAME\n";
cout<<"\n\t 1. Choose any number between 1 to 10\n\t 2. If you win you will get 2 times of money you bet\n\t 3. If you bet on wrong number you will lose your betting amount\n\n";
cout<<endl;
} //end braces for function definition
Monday, 24 June 2013
Best css drop down menu list for blogger
Today I am going to post a list of css drop down menu for your blog or website. This drop down menu Fully created in CSS and it does not effect your blog or website load time. Now a days most of blogger use drop down menu to make blog or website more attractive. Drop down menu is a best way to attract your visitors to visit again on your blog. Drop down menu play effective role in the development of an effective and user friendly blog. This drop down support almost every browser. You can easily change the color according to your website color scheme. If you have any problem in changing color feel free to ask by using comment box below.
Live Demo..
Live Demo..
How to Add Drop Down menu to your blog:
1. Go to Blogger.com and click on template.
2. Backup your template before adding it.
3. Click on Edit Html and Find the Code by using CTRL+F.
4. Find following Code ]]></:skin> and add below Css code just above it.
1. Black Shiny Drop Down Menu:
Live Demo..
#menu-bar {
width: 95%;
margin: 0px 0px 0px 0px;
padding: 7px 7px 15px 11px;
height: 23px;
line-height: 100%;
border-radius: 7px;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
box-shadow: 0px 5px 11px #2C2C66;
-webkit-box-shadow: 0px 5px 11px #2C2C66;
-moz-box-shadow: 0px 5px 11px #2C2C66;
background: #FFFFFF;
background: linear-gradient(top, #999999, #404040);
background: -ms-linear-gradient(top, #999999, #404040);
background: -webkit-gradient(linear, left top, left bottom, from(#999999), to(#404040));
background: -moz-linear-gradient(top, #999999, #404040);
border: solid 0px #6D6D6D;
position:relative;
z-index:999;
}
#menu-bar li {
margin: 0px 0px 6px 0px;
padding: 0px 1px 0px 7px;
float: left;
position: relative;
list-style: none;
}
#menu-bar a {
font-weight: normal;
font-family: verdana;
font-style: normal;
font-size: 13px;
color: #DDE7DB;
text-decoration: none;
display: block;
padding: 6px 20px 6px 20px;
margin: 0;
margin-bottom: 6px;
border-radius: 4px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
text-shadow: 1px 2px 0px #000000;
}
#menu-bar li ul li a {
margin: 0;
}
#menu-bar .active a, #menu-bar li:hover > a {
background: #01394F;
background: linear-gradient(top, #FFFFFF, #FFFFFF);
background: -ms-linear-gradient(top, #FFFFFF, #FFFFFF);
background: -webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#FFFFFF));
background: -moz-linear-gradient(top, #FFFFFF, #FFFFFF);
color: #000000;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
text-shadow: 0px 1px 0px #FFFFFF;
}
#menu-bar ul li:hover a, #menu-bar li:hover li a {
background: none;
border: none;
color: #666;
-box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
#menu-bar ul a:hover {
background: #3220D4 !important;
background: linear-gradient(top, #ECECEC, #65636E) !important;
background: -ms-linear-gradient(top, #ECECEC, #65636E) !important;
background: -webkit-gradient(linear, left top, left bottom, from(#ECECEC), to(#65636E)) !important;
background: -moz-linear-gradient(top, #ECECEC, #65636E) !important;
color: #FFFFFF !important;
border-radius: 0;
-webkit-border-radius: 0;
-moz-border-radius: 0;
text-shadow: 0px 0px 3px #FFFFFF;
}
#menu-bar ul {
background: #FFFFFF;
display: none;
margin: 0;
padding: 0;
width: 188px;
position: absolute;
top: 23px;
left: 0;
border: solid 0px #FFFFFF;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-webkit-box-shadow: 0px 2px 16px #060522;
-moz-box-shadow: 0px 2px 16px #060522;
box-shadow: 0px 2px 16px #060522;
}
#menu-bar li:hover > ul {
display: block;
}
#menu-bar ul li {
float: none;
margin: 0;
padding: 0;
}
#menu-bar ul a {
padding:14px 0px 10px 15px;
color:#191919 !important;
font-size:12px;
font-style:normal;
font-family:verdana;
font-weight: normal;
text-shadow: 4px 2px 0px #FFFFFF;
}
#menu-bar ul li:first-child > a {
border-top-left-radius: 3px;
-webkit-border-top-left-radius: 3px;
-moz-border-radius-topleft: 3px;
border-top-right-radius: 3px;
-webkit-border-top-right-radius: 3px;
-moz-border-radius-topright: 3px;
}
#menu-bar ul li:last-child > a {
border-bottom-left-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
-moz-border-radius-bottomleft: 3px;
border-bottom-right-radius: 3px;
-webkit-border-bottom-right-radius: 3px;
-moz-border-radius-bottomright: 3px;
}
#menu-bar:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
#menu-bar {
display: inline-block;
}
html[xmlns] #menu-bar {
display: block;
}
* html #menu-bar {
height: 1%;
}
Greenish Drop Down Menu:
#menu-bar {
width: 95%;
margin: 0px 0px 0px 0px;
padding: 12px 24px 16px 16px;
height: 26px;
line-height: 100%;
border-radius: 0px;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
box-shadow: 0px 5px 0px #646B62;
-webkit-box-shadow: 0px 5px 0px #646B62;
-moz-box-shadow: 0px 5px 0px #646B62;
background: #FFFFFF;
background: linear-gradient(top, #5F9599, #2C3025);
background: -ms-linear-gradient(top, #5F9599, #2C3025);
background: -webkit-gradient(linear, left top, left bottom, from(#5F9599), to(#2C3025));
background: -moz-linear-gradient(top, #5F9599, #2C3025);
border: solid 0px #6D6D6D;
position:relative;
z-index:999;
}
#menu-bar li {
margin: 0px 0px 0px 0px;
padding: 2px 1px 0px 7px;
float: left;
position: relative;
list-style: none;
}
#menu-bar a {
font-weight: normal;
font-family: georgia;
font-style: normal;
font-size: 13px;
color: #DDE7DB;
text-decoration: none;
display: block;
padding: 7px 20px 6px 20px;
margin: 0;
margin-bottom: 0px;
border-radius: 50px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
text-shadow: 0px 2px 0px #000000;
}
#menu-bar li ul li a {
margin: 0;
}
#menu-bar .active a, #menu-bar li:hover > a {
background: #000000;
background: linear-gradient(top, #FFFFFF, #F5E6F2);
background: -ms-linear-gradient(top, #FFFFFF, #F5E6F2);
background: -webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#F5E6F2));
background: -moz-linear-gradient(top, #FFFFFF, #F5E6F2);
color: #000017;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
text-shadow: 0px 1px 0px #FFFFFF;
}
#menu-bar ul li:hover a, #menu-bar li:hover li a {
background: none;
border: none;
color: #666;
-box-shadow: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
#menu-bar ul a:hover {
background: #000000 !important;
background: linear-gradient(top, #213F40, #65636E) !important;
background: -ms-linear-gradient(top, #213F40, #65636E) !important;
background: -webkit-gradient(linear, left top, left bottom, from(#213F40), to(#65636E)) !important;
background: -moz-linear-gradient(top, #213F40, #65636E) !important;
color: #FFFFFF !important;
border-radius: 0;
-webkit-border-radius: 0;
-moz-border-radius: 0;
text-shadow: 0px 0px 3px #FFFFFF;
}
#menu-bar ul {
background: #FFFFFF;
display: none;
margin: 0;
padding: 0;
width: 188px;
position: absolute;
top: 26px;
left: 0;
border: solid 0px #FFFFFF;
border-radius: 17px;
-webkit-border-radius: 17px;
-moz-border-radius: 17px;
-webkit-box-shadow: 0px 2px 16px #060522;
-moz-box-shadow: 0px 2px 16px #060522;
box-shadow: 0px 2px 16px #060522;
}
#menu-bar li:hover > ul {
display: block;
}
#menu-bar ul li {
float: none;
margin: 0;
padding: 0;
}
#menu-bar ul a {
padding:14px 0px 10px 15px;
color:#191919 !important;
font-size:12px;
font-style:normal;
font-family:verdana;
font-weight: normal;
text-shadow: 4px 2px 0px #FFFFFF;
}
#menu-bar ul li:first-child > a {
border-top-left-radius: 17px;
-webkit-border-top-left-radius: 17px;
-moz-border-radius-topleft: 17px;
border-top-right-radius: 17px;
-webkit-border-top-right-radius: 17px;
-moz-border-radius-topright: 17px;
}
#menu-bar ul li:last-child > a {
border-bottom-left-radius: 17px;
-webkit-border-bottom-left-radius: 17px;
-moz-border-radius-bottomleft: 17px;
border-bottom-right-radius: 17px;
-webkit-border-bottom-right-radius: 17px;
-moz-border-radius-bottomright: 17px;
}
#menu-bar:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
#menu-bar {
display: inline-block;
}
html[xmlns] #menu-bar {
display: block;
}
* html #menu-bar {
height: 1%;
}
5. After adding this code click on Layout >> Add a gadget>> HTml and Javascript abd this below code.
6. Click on Save button and Enjoy drop down menu on your blog.
<ul id="menu-bar">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Products</a>
<ul>
<li><a href="#">Products Sub Menu 1</a></li>
<li><a href="#">Products Sub Menu 2</a></li>
<li><a href="#">Products Sub Menu 3</a></li>
<li><a href="#">Products Sub Menu 4</a></li>
</ul>
</li>
<li><a href="#">Services</a>
<ul>
<li><a href="#">Services Sub Menu 1</a></li>
<li><a href="#">Services Sub Menu 2</a></li>
<li><a href="#">Services Sub Menu 3</a></li>
<li><a href="#">Services Sub Menu 4</a></li>
</ul>
</li>
<li><a href="#">About</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
6. Click on Save button and Enjoy drop down menu on your blog.
Customization:
1. Change # with the link you use.
2. If you want to change the color of drop down menu. Use comment box i guide you how you can change the color easily.
Need Help?
If you need any help about drop down menu. Leave comment below by using comment box. I am always here to help you.
Your feedback is important for us please give feedback about drop down menu.