Sie sind auf Seite 1von 17

Plate No.

FLOWCHART: START

Prompt user to
select a choice

Cin >> choice;

If a<20; a++
case a<19;a++
a<20;a++
a;

If R >0;r--
c>r;c
case
k<r;k++
b;

STOP
SOURCE CODE:

#include "iostream"

#include "stdio.h"

#include <cstdlib>

using namespace std;

int main()

char choice;

m:

cout << "Pls select below" << endl;

cout << "a. Square \nb. Inverted Triangle" << endl;

cin >> choice;

cout << endl << endl;

switch(choice)

case 'a' : //Choice A - Square

for (int a = 0; a < 20; a++)


{

cout << " *";

cout << endl;

for (int a = 0; a < 19; a++)

cout << " * *";

cout << endl;

for (int a = 0; a < 20; a++)

cout << " *";

cout << endl;

system("pause");

system("CLS");

goto m;

break;

case 'b' :

//second

for ( int r = 10; r> 0; r--)


{

for ( int c= 10; c > r; c--)

cout << " ";

for(int k=0;k<r;k++)

cout<<"*";

cout << endl;

cout << endl;

system("pause");

system("CLS");

goto m;

break;

return 0;

}
OUTPUT:
Plate No. 3

FLOWCHART: START

Declare variables;

A Main Menu

Switch (choice);

Case Case Cas


B A e C

Prompt user to Prompt user to END


input a no. input a no.

int x = range; x >= 0; int x = 0; x <= range;


x-- x++

Decreasing Increasing
results results

A
SOURCE CODE:

#include<iostream>

using namespace std;

int main()
{
int range;
char choice;

m:
cout<< "************ Main Menu ************"<<endl;
cout<< "\n\n A. Increasing"<<endl;
cout<< "\n\n B. Decreasing"<<endl;
cout<< "\n\n C. Exit"<<endl;
cout<< "***********************************"<<endl;
cout<< "Select a choice:";
cin>>choice;

system("cls");

switch(choice)
{
case 'A':
break;
case 'a':
cout<<"\n\n Increasing"<<endl;
cout<<"\n Enter desired number:";
cin>>range;

for (int x = 0; x <= range; x++)


{
cout<< x << ", ";
}
cout<<endl;
system("pause");
system("cls");
goto m;
break;

cout<<endl;

case 'B':
break;
case 'b':
cout<<"\n\n Decreasing"<<endl;
cout<<"\n Enter desired number:";
cin>>range;

for ( int x = range; x >= 0; x--)


{
cout<< x << ",";
}
cout<<endl;
system("pause");
system("CLS");
goto m;
break;

case 'C':

break;
case 'c':

break;
}
return 0;
}
OUTPUT:
Plate No 4.

FLOWCHART: START

Declare
functions;

Ask user to select a mode;

If Initialize
input= timeInfo;
M Read declared
functions;

read time
convention;
Initialize
timeInfo; Set console
display;
Read time
convention;

Time =PM If
hrs
>=12

Display localtime(12
Time =AM hr)

For t=0;t<11;t++

Display localtime(24
hr)

END
SOURCE CODE:

#include <ctime>

#include <conio.h>

#include <iostream>

#include <string>

#include <functional>

#include <windows.h>

using namespace std;

HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);

COORD CursorPosition;

void Draw(int style, int col, int row, int length,int amount, bool fill, int sw );

void gotoXY(int x, int y );

void gotoXY(int x, int y, string text);

void setcursor(bool visible, DWORD size);

int main() { setcursor(0,0);

int hours, minutes, seconds, t;

struct tm * timeinfo; bool Military_Time = false;

string AM_PM;

string Segment[11][10]={ {" \x11\xDB\xDB\xDB\x10 "," "," \x11\xDB\xDB\xDB\x10 "," \x11\xDB\xDB\xDB\x10 "," ","
\x11\xDB\xDB\xDB\x10 "," \x11\xDB\xDB\xDB\x10 "," \x11\xDB\xDB\xDB\x10 "," \x11\xDB\xDB\xDB\x10 ","
\x11\xDB\xDB\xDB\x10 "}, {"\x1E \x1E"," \x1E"," \x1E"," \x1E","\x1E \x1E","\x1E ","\x1E "," \x1E","\x1E \x1E","\x1E
\x1E"}, {"\xDB \xDB"," \xDB"," \xDB"," \xDB","\xDB \xDB","\xDB ","\xDB "," \xDB","\xDB \xDB","\xDB \xDB"}, {"\xDB
\xDB"," \xDB"," \xDB"," \xDB","\xDB \xDB","\xDB ","\xDB "," \xDB","\xDB \xDB","\xDB \xDB"}, {"\x1F \x1F"," \x1F","
\x1F"," \x1F","\x1F \x1F","\x1F ","\x1F "," \x1F","\x1F \x1F","\x1F \x1F"}, {" "," ", " \x11\xDB\xDB\xDB\x10 ","
\x11\xDB\xDB\xDB\x10 "," \x11\xDB\xDB\xDB\x10 "," \x11\xDB\xDB\xDB\x10 "," \x11\xDB\xDB\xDB\x10 "," ","
\x11\xDB\xDB\xDB\x10 "," \x11\xDB\xDB\xDB\x10 "}, {"\x1E \x1E"," \x1E","\x1E "," \x1E"," \x1E"," \x1E","\x1E
\x1E"," \x1E","\x1E \x1E"," \x1E"}, {"\xDB \xDB"," \xDB","\xDB "," \xDB"," \xDB"," \xDB","\xDB \xDB"," \xDB","\xDB
\xDB"," \xDB"}, {"\xDB \xDB"," \xDB","\xDB "," \xDB"," \xDB"," \xDB","\xDB \xDB"," \xDB","\xDB \xDB"," \xDB"},
{"\x1F \x1F"," \x1F","\x1F "," \x1F"," \x1F"," \x1F","\x1F \x1F"," \x1F","\x1F \x1F"," \x1F"}, {" \x11\xDB\xDB\xDB\x10
"," "," \x11\xDB\xDB\xDB\x10 "," \x11\xDB\xDB\xDB\x10 "," "," \x11\xDB\xDB\xDB\x10 "," \x11\xDB\xDB\xDB\x10
"," "," \x11\xDB\xDB\xDB\x10 "," \x11\xDB\xDB\xDB\x10 "} };

string Colon[11] = {" "," "," "," \xFE "," "," "," "," \xFE "," "," "," "};

Draw(2,2,5,76,15,0,2);

gotoXY(26,11,"Pressing the \"M\" key");

gotoXY(26,13,"toggles Military Time");


Sleep(2000); Draw(1,4,6,72,13,1,0);

gotoXY(73,8,"HR");

do { time_t rawtime;

time ( &rawtime );

timeinfo = localtime( &rawtime );

hours = timeinfo->tm_hour; seconds = timeinfo->tm_sec; minutes = timeinfo->tm_min; if (_kbhit()) { char ch =


_getch();

ch = toupper(ch); if (ch == 'M') { Military_Time = !Military_Time; ch = ' '; } } if( Military_Time) { AM_PM = " ";
gotoXY(73,7,"24"); } else { AM_PM = "AM"; gotoXY(73,7,"12"); if ( hours >= 12) AM_PM = "PM"; if ( hours == 0 )
hours = 12;

if ( hours > 12) hours -=12; } for(t=0;t<11;t++) { gotoXY(6,7+t);

cout << Segment[t][hours/10] << " " << Segment[t][hours%10] << Colon[t] << Segment[t][minutes/10] << " " <<
Segment[t][minutes%10] << Colon[t] << Segment[t][seconds/10] << " " << Segment[t][seconds%10]; }
gotoXY(73,17, AM_PM); Sleep(1000); } while (true); }

void Draw(int style, int col, int row, int length,int amount, bool fill, int sw ) { // Draws a 1 or 2 line box int a; if ( sw
>4) sw = 4; style=(style-1)*6; char box[24]; char shdw[5]; box[0] = '\xDA'; box[1] = '\xBF'; box[2] = '\xC0'; box[3] =
'\xD9'; box[4] = '\xB3'; box[5] = '\xC4'; box[6] = '\xC9'; box[7] = '\xBB'; box[8] = '\xC8'; box[9] = '\xBC'; box[10] =
'\xBA'; box[11] = '\xCD'; box[12] = '\xD5';// + box[13] = '\xB8';// + box[14] = '\xD4';// + box[15] = '\xBE';// + box[16] =
'\xB3';// box[17] = '\xCD';// - box[18] = '\xD6';// + box[19] = '\xB7';// + box[20] = '\xD3';// + box[21] = '\xBD';// +
box[22] = '\xBA';// box[23] = '\xC4';// - shdw[1] = '\xB0';// shdw[2] = '\xB1';// shdw[3] = '\xB2';// shdw[4] =
'\xDB';// char tl,tr,bl,br,side,edge,shadow; tl = box[style]; tr = box[style+1]; bl = box[style+2]; br = box[style+3];
side = box[style+4]; edge = box[style+5]; shadow = shdw[sw]; string Line(length-2,edge); string
Shadow(length,shadow); string Fill(length-2, ' '); gotoXY(col,row);

cout << tl << Line << tr; for (a = 1; a <amount-1;a++) { gotoXY(col,row+a); cout << side; if (fill) cout << Fill; else
gotoXY(col+length-1,row+a); cout << side; if (sw) cout << shadow; } gotoXY(col,(amount+row)-1);

cout << bl << Line << br; if (sw) { cout << shadow; gotoXY(col+1,row+amount , Shadow ); } } void gotoXY(int x,
int y) { CursorPosition.X = x; CursorPosition.Y = y; SetConsoleCursorPosition(console,CursorPosition); } void
gotoXY(int x, int y, string text) { CursorPosition.X = x; CursorPosition.Y = y;

SetConsoleCursorPosition(console,CursorPosition); cout << text; } void setcursor(bool visible, DWORD size) //


set bool visible = 0 - invisible, bool visible = 1 - visible { if(size == 0) { size = 20; // default cursor size }
CONSOLE_CURSOR_INFO lpCursor; lpCursor.bVisible = visible;

lpCursor.dwSize = size; SetConsoleCursorInfo(console,&lpCursor); }


OUTPUT:

Das könnte Ihnen auch gefallen