Thursday, 24 January 2013

Directory


#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include<string>


COORD coord={0,0}; // function to set the cursor point
         void gotoxy(int x,int y)
       {
             coord.X=x;
             coord.Y=y;
             SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
       }


using namespace std;



int main()
{  int check=0;
    int x=0;
    int y=0;
    string enter;
    string dir[6][5]={{"Country","Capital","Religion","Language","Land Area"},
                      {"pakistan","islamabad","islam","urdu","709,696 km"},
                        {"indea","newDelhi","hindu","hindi","3,287,590 sq km"},
                        {"afghanistan","kabul","islam","pashti","647,500 sq km"},
                        {"china","beijing","daoist","chinese","9,596,960 sq km"},
                        {"america","washington","protestant","english","9,631,420 sq km"}};
cout << "Type anyone thing to get information regarding any country\nNAME, Capital, Religion, language or country area\n";
cin >> enter;

for(int i=1; i<6; i++)
for(int j=0; j<5; j++)
{
  if(dir[i][j]==enter)
  { check=1;
      for(int i=0; i<5;i++)
        {

gotoxy(x,4);
                cout << dir[0][i]; if(x>0){gotoxy(x-5,4);cout <<"|";}
x=x+15;

                if(i==4)
                {
                    cout << endl;
                }

       }

    for(int k=0; k<5; k++)
    {

gotoxy(y,6);
        cout << dir[i][k] ; if(y>0){gotoxy(y-5,6);cout <<"|" << endl;}
        y=y+15;


   }

   }
}

if(check==0)
{cout << "Your search by keywords " <<enter << "is not registered.\nNOTE: All spells should be correct and in small Letters";
}




     cin.get();
     system("pause");

    return 0;
}

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Enterprise Project Management