1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#include<iostream>
#include <conio.h>
#include <Windows.h>
using std::cout;
using std::endl;
void frame(int column, int row, int wide, int high);
void gotoxy(int x, int y);
int main()
{
int number;
printf("Enter the atomic number of element(s): (Enter a '1' only) ");
scanf_s("%d", &number);
switch (number)
{
case 1:
frame(20,9,20,6);
gotoxy(21,10);
cout<<"atomic number: 1";
gotoxy(25,13);
cout<<"symbol: H";
break;
default:printf("\n unknown element");
}
gotoxy(20,25);
_getch();
return 0;
}
void frame(int column, int row, int wide, int high)
{
gotoxy(column, row);
cout << "\xDA";
for(int x=1;x<wide-1;x++)
cout << "\xC4";
cout << "\xBF";
for(int x=1;x<high-1;x++)
{
gotoxy(column, row+x);
cout<<"\xB3";
gotoxy(column+(wide-1), row+x);
cout<<"\xB3";
}
gotoxy(column, row+high-1);
cout << "\xC0";
for(int x=1;x<wide-1;x++)
cout << "\xC4";
cout << "\xD9";
}
void gotoxy(int x, int y)
{
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;
CursorPosition.X = x;
CursorPosition.Y = y;
SetConsoleCursorPosition(console, CursorPosition);
}
|