流程图 高手快进来
我看的懂程序,但是自己画不出来程序流程图有谁能够帮一把,画一个流程图!
在c-free5.0下能够运行
有谁能够帮一把,画一个流程图!
一个很简单的计算器程序
程序如下#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include <windows.h>
#include<dos.h>
//----------------坐标定位函数----------------
void gotoxy(int x, int y)
{
COORD pos = {x,y};
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOut, pos);
}
//----------------文本闪烁函数------------------
void SetColor(unsigned short ForeColor=7,
unsigned short BackGroundColor=0)
{
HANDLE hCon=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon,ForeColor|BackGroundColor);
}
//------------------计算部分------------------
double Add(double num1, double num2) //加
{
return num1 + num2;
}
double Sub(double num1, double num2) //减
{
return num1 - num2;
}
double Mul(double num1, double num2) //乘
{
return num1 * num2* num2;
}
double Div(double num1, double num2) //除
{
if (num2 == 0)
{
gotoxy (4,5);
printf("input error!");//报错,除数不能为零
return 0;
}
return num1 / num2;
}
void Menu()
{
double number1, number2;
double result=0;
char chooce;
scanf("%lf%c%lf",&number1,&chooce,&number2);
switch(chooce)
{
case '+':
result = Add(number1,number2);
break;
case '-':
result = Sub(number1,number2);
break;
case '*':
result = Mul(number1,number2);
break;
case '/':
result = Div(number1,number2);
break;
default:
printf("input error!");
break;
}
gotoxy(10,4);
printf("=%f\n",result);
gotoxy (4,19);
printf("Continue? (Y/N)");//输入Y或N决定是否进行下一次计算
chooce = getch();
if(chooce == 'n' || chooce == 'N')
{
exit(0);
}
}
main()
{
char hit;
while(1)
{
system("cls");//清除以输入的算式
gotoxy(1,2);
printf("\n");
printf(" ┌───────────────┐ \n");
printf(" │ │ \n");
printf(" │ │ \n");
printf(" ├───────────────┤ \n");
printf(" │ 1 2 3 + - │ \n");
printf(" │ │ \n");
printf(" │ 4 5 6 * / │ \n");
printf(" │ │ \n");
printf(" │ 7 8 9 = \x1b │ \n");
printf(" │ │ \n");
printf(" │ 0 . End │ \n");
printf(" └───────────────┘ \n");
gotoxy(4,17);
printf("提示:按End键终止计算!");
//---------------------文本闪烁效果--------------------
while(!kbhit())//当没有按键被按下时
{
for(int i=2; i<5; i++)
{
SetColor(i);//变换绿,兰,红色
Sleep(400);
gotoxy(4,1);
printf("简单计算机!");
SetColor();
}
}
//----------------------检测按键-----------------------
while(kbhit())//有按键按下后
{
hit=getch();
if(hit==-32)
exit(0);//按End结束计算
else break;
}
gotoxy(4,4);
system("color 7");//文本停止闪烁并恢复白色
Menu();
}
}