大专实训周——计算机项目

概要

        这个计算机与其他不同的是有科学计算机的内容,也有基本计算机的内容。使用函数之间的调用,涵盖c语言的大部分基础和c++的内容,涉及基本项目逻辑。学完c语言和c++基础的可以很快速的读懂此项目。

整体架构流程

此项目的基本功能:

        基本运算
  1.                 加减运算
  2.                 乘除运算
  3.                 乘方运算
        进制转换
  1.                 十进制转其他进制
  2.                 其他进制转十进制
        排列组合
  1.                 排列数
  2.                 组合数
        几何运算
  1.                 梯形面积
  2.                 三角形面积        
  3.                 圆形面积        
  4.                 长(正)方形面积        
  5.                 扇形面积

        这些功能模块基础上都加上返回上一层操作&返回首页

项目的显示页面有:

        登录页面

        首页页面

        功能选择页面

        说明页面

        其它页面

        基本运算页面

        进制运算页面

        排列组合页面

        几何运算页面

        进制选择页面

        其它进制转十进制选择页面

        排列组合选择页面

        几何运算功能选择页面

全部代码

头文件

#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<Windows.h>

using namespace std;
#define _CRT_SECURE_NO_WARNINGS//禁用安全函数警告
#pragma warning(disable:6031)//禁用 6031 的安全警告

void SM();										//说明函数
void QT();										//其它函数

void index_36();								//首页页面
void operationIndex_36();						//功能页面
void fundamentalOperation_36();					//基本运算
void numericalBaseConversion_36();				//进制运算
void permutationAndCombination_36();			//排列组合
void geometryCalculation_36();					//几何运算

double ti();			//梯形面积
double yuan();			//圆面积
double san();			//三角形面积
double zheng();			//矩形面积
double shan();			//扇形面积
int CC();				//组合
int AA();				//排列

int SZ();
void QTZSYM();			//其它进制转十进制页面
int JBYS();				//基本运算

int SLZS();				//16转10
int EZS();				//2转10
int BZS();				//8转10

void MMJM();			//密码
void HYJM();			//欢迎界面
void SJYS();			//时间元素

源文件

main部分

int main()
{
	//index_36();											//进入页面
	HYJM();
	return 0;
}
void index_36()											//进入页面
{
	system("cls");
	cout<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t-计算机-"<<endl;
	cout << "\t\t\t\t\t\t  QvQ" << endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t1.运算开始\n"<<endl;
	cout<<"\t\t\t\t\t\t2.使用说明\n"<<endl;
	cout<<"\t\t\t\t\t\t3.其它\n"<<endl;
	cout<<"\t\t\t\t\t\t4.关机\n" << endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t请输入操作<1/2/3/4>:";
	int e;
	while(true)
	{
		cin>>e;
		switch(e)
		{
			case 1:
				operationIndex_36();//开始使用
				break;
			case 2:
				SM();//说明页面
				break;
			case 3:
				QT();//其它页面
				break;
			case 4:
				system("cls");
				exit(0);//其它页面	
				break;
			default:
				cout<<"\t\t\t\t\t\t输入有误,重新输入!\n"<<endl;
				continue;
		}
	
	}
} 
//
//
//
//
//
void  operationIndex_36()								//功能选择页面
{
	system("cls");
	cout<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t1.基本运算"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t2.进制运算"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t3.排列运算"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t4.几何运算"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t5.返回首页"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t请输入操作<1/2/3/4/5>:";
	int e;
	while(1)
	{
		
		cin>>e;
		if(e==1)
		{
			 fundamentalOperation_36();//基本运算函数
			break;
		}
		else if(e==2)
		{
			numericalBaseConversion_36();//进制转换函数
			break;
		}
		else if(e==3)
		{
			permutationAndCombination_36();//排列组合函数
			break;
		}
		else if(e==4)
		{
			geometryCalculation_36();//几何计算函数
			break;
		}
		else if(e==5)
		{
			index_36();//返回首页
		}
		else
		{
			cout<<"输入有误,请重新输入:";
			cin>>e;
		}
	}
}
														//功能区
void fundamentalOperation_36()							//基本运算函数
{
	JBYS();
}
//
//
//
//
//
void numericalBaseConversion_36()						//进制转换函数
{
	system("cls");
	cout<<endl;	
	cout << "\t\t\t\t\t\t--进制运算--" << endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t1.十进制转其它进制"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t2.其它进制转十进制"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t3.返回上一层"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t4.返回首页"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t请输入操作<1/2/3/4>:";
	int e;
	while(true)
	{
		cin>>e;
		switch(e)
		{
			case 1:
				SZ();
				break;
			case 2:
				QTZSYM();
				break;
			case 3:
				operationIndex_36();
				break;
			case 4:
				index_36();
				break;
			default:
				cout<<"\t\t\t\t\t\t输入有误,重新输入!\n"<<endl;
				continue;
		}
	}
}
//
//
//
//
//
void permutationAndCombination_36()						//排列组合函数
{
	system("cls");
	cout<<endl;
	cout << "\t\t\t\t\t\t--排列运算--" << endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t1.排列数"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t2.组合数"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t3.返回上一层"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t4.返回首页"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t请输入操作<1/2/3/4>:";
	int e;
	while(true)
	{
		cin>>e;
		switch(e)
		{
			case 1:
				AA();
				break;
			case 2:
				CC();
				break;
			case 3:
				operationIndex_36();
				break;
			case 4:
				index_36();
				break;
			default:
				cout<<"\t\t\t\t\t\t输入有误,重新输入!\n"<<endl;
				continue;
		}
	}
}	
//
//
//
//
//
void geometryCalculation_36()						//几何运算				
{
	system("cls");
	cout<<endl;
	cout << "\t\t\t\t\t\t--几何运算--" << endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t1.梯形面积"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t2.三角形面积"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t3.圆形面积"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t4.长(正)方形面积"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t5.扇形面积"<<endl;
	cout<<endl;
	cout <<"\t\t\t\t\t\t6.返回上一层" << endl;
	cout << endl;
	cout<<"\t\t\t\t\t\t7.返回首页"<<endl;
	cout<<endl;
	cout<<"\t\t\t\t\t\t请输入操作<1/2/3/4/5/6/7>:";
	int e;
	while(true)
	{
		cin>>e;
		switch(e)
		{
			case 1:
				 ti();
				break;
			case 2:
				san();
				break;
			case 3:
				yuan();
				break;
			case 4:
				zheng();
				break;
			case 5:
				shan();
				
				break;
			case 6:
				operationIndex_36();
				break;
			case 7:
				index_36();
				break;
			default:
				cout<<"\t\t\t\t\t\t输入有误,重新输入!\n"<<endl;
				continue;
		}
	}
}



欢迎页面
void HY() 
{
	cout << "\t\t\t" << "	                   _ooOoo_   " << endl;
	cout << "\t\t\t" << " 	                  o8888888o  " << endl;
	cout << "\t\t\t" << " 	                  88“ . ”88 " << endl;
	cout << "\t\t\t" << " 	                  (| -_- |)  " << endl;
	cout << "\t\t\t" << " 	                  O\\  =  /O  " << endl;
	cout << "\t\t\t" << " 	               ____/`---'\\____" << endl;
	cout << "\t\t\t" << " 	              .'  \\|     |//  `." << endl;
	cout << "\t\t\t" << " 	            /  \\|||  :  |||//  \\" << endl;
	cout << "\t\t\t" << " 	           /  _||||| -:- |||||-  \\" << endl;
	cout << "\t\t\t" << " 	           |   | \\\\\\\  -  /// |   |  " << endl;
	cout << "\t\t\t" << " 	           | \\_|  ''\\-/''  |   |" << endl;
	cout << "\t\t\t" << " 	           \\  .-\\__  `-`  ___/-. /" << endl;
	cout << "\t\t\t" << " 	         ___`. .'  /-.-\\  `. . __" << endl;
	cout << "\t\t\t" << " 	      ."" '<  `.___\\_<|>_/___.'  >'""." << endl;
	cout << "\t\t\t" << " 	     | | :  `- \\`.;`\\ _ /`;.`/ - ` : | |" << endl;
	cout << "\t\t\t" << " 	     \\  \\ `-.   \\_ __\\ /__ _/   .-` /  /" << endl;
	cout << "\t\t\t" << " 	======`-.____`-.___\\_____/___.-`____.-'======" << endl;
	cout << "\t\t\t" << " 	                   `=-='" << endl;
	char D[] = "HELLO WELCOME";
	cout << "\t\t\t\t\t       ";
	for (int i = 0; i<13; i++)
	{
		std::cout<< D[i];
		Sleep(250);
	}
	  SJYS();
	  MMJM();
	  
}
void HYJM() 
{
	HY();
}
密码功能
int MM() 
{
	//写密码程序需要用两个字符数组操作
	char mima[] = "2316020336";
	char R[] = "0";
	cout << "\n\n\n\n\t\t\t\t\t       " << "请输入密码:"<<"\n\t\t\t\t\t\t";
	cin >> R;
	if (strcmp(mima,R)==0)
	{
		index_36();											//进入页面
	}
	else 
	{
		cout << "密码错误" << endl;
		Sleep(1000);
		exit(0);
	}
	return 0;
}
void MMJM() 
{
	MM();
}
时间元素
#include <time.h>

int SJ() {
    time_t rawtime;
    struct tm* timeinfo;

    time(&rawtime);
    timeinfo = localtime(&rawtime);

    char buffer[80];
    cout << "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
    strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", timeinfo);
    printf("登录时间: %s\n", buffer);
    return 0;
}

void SJYS() 
{
    SJ();
}
说明使用页面
void SM()
{
	system("cls");
	cout << endl;
	cout << endl;
	cout << "\t\t\t\t\t\t太长了,你上网搜\n" << endl;
	cout << endl;
	//
	//
	//
	int s;
	cout << "\n\t\t\t\t\t\t返回按1:";
	cin >> s;
	if (s == 1)
	{
		index_36();
	}

}
其它页面
void QT()
{
	system("cls");
	cout << endl;
	cout << endl;
	cout << "\t\t\t\t\t\t还没开发!\n" << endl;
	cout << endl;
	//
	//
	//
	int s;
	cout << "\n\t\t\t\t\t\t返回按1:" ;
	cin >> s;
	if (s == 1)
	{
		index_36();
	}
	
}
基本运算
//结构体叫Num
typedef struct
{
	float a[100];
	int top;
}Num;

//结构体叫Symb
typedef struct
{
	char a[100];
	int top;
}Symb;

void IniStack(Num* num, Symb* symb)  //初始化
{
	num->top = -1;
	symb->top = 0;
}
//假如读出的运算符的优先级高于运算符栈栈顶运算符的优先级,
//将其压入运算符栈,读取下一个符号。
//假如读出的运算符优先级等于或者低于运算符栈栈顶运算符的优先级,
//则从操作数栈连续退出两个操作数,
//从运算符栈中退出一个运算符,然后做相应运算,
//并将运算结果压入操作数栈,不读入下一个符号。
int compare(char str)  //判断符号优先级的函数
{
	if (str == '!')
		return 0;
	if (str == '+' || str == '-')
		return 1;
	if (str == '/' || str == '*')
		return 2;
}

float YunSuan(float a, float b, char str) //进行两个数字间的运算的函数
{
	if (str == '+')
		return a + b;
	if (str == '-')
		return a - b;
	if (str == '/')
		return a / b;
	if (str == '*')
		return a * b;
}



int JBYS()
{
	system("cls");
	cout << endl;
	cout << endl;
	cout << "\t\t\t\t\t\t\t\t     >>>基本运算" << endl;
	cout << endl;
	cout << endl;

	Num* num = (Num*)malloc(sizeof(Num));
	Symb* symb = (Symb*)malloc(sizeof(Symb));
	IniStack(num, symb);
	char str[50];  //记录输入的内容
	int flag = -1;  //设置标志符,根据值来判断要进行的操作:将数字入数字栈  将符号入符号栈  将两个数进行运算
	printf("\t\t\t\t\t\t请输入表达式:\n\t\t\t\t\t\t");
	scanf_s("%s", str, 50);
	float x = 0.0;
	int length = strlen(str);
	str[length++] = '!';  //末尾加上! 用于判断
	for (int i = 0; i < length;)
	{
		if (str[i] <= '9' && str[i] >= '0')
		{
			x *= 10;
			x += str[i++] - '0';    //这个if用来记录数字,比如11,在str中是分开的1,1,必须得做乘法加法运算才能表达为11
			flag = 1;
		}
		else
		{
			if (flag == 1)  //属于数字,得入数字栈
			{
				num->a[++num->top] = x;
				x = 0; flag = -1;    //数字入完了就到符号了,flag改成-1
			}
			if (compare(symb->a[symb->top]) < compare(str[i]))   //根据符号优先级比较,例如:a+b*c 这里逻辑上可以看成a+(b*c)
				symb->a[++symb->top] = str[i++];
			else
			{
				float a = num->a[num->top--];
				float b = num->a[num->top];
				num->a[num->top] = YunSuan(b, a, symb->a[symb->top--]);   //例如输入的是:a+b-c  经过这一步就变成了(a+b)-c
				if (str[i] == '!' && symb->top == 0)         //末尾设置!的作用就是用来判断符号栈是否已经为空  就是运算是否结束了
					break;
			}

		}
	}
	printf("\t\t\t\t\t\t最终的结果为:\n\t\t\t\t\t\t%lf\n", num->a[num->top]);
	
	//
	//
	//
	int s;
	cout << "\n\t\t\t\t\t\t继续使用就输入1,否则就回到上一层0>>>" ;
	cin >> s;
	if (s == 1)
	{
		JBYS();
	}
	else if (s == 0) {
		operationIndex_36();
	}
	return 0;
}

十进制转二进制、八进制、十六进制

void SZE(int d)                       //十进制装二进制
{
    int i, j, x = 0;
    int a[1000];
    x = d;
    for (i = 0;; i++)
    {
        a[i] = x % 2;
        x = x / 2;
        if (x == 0)
        {
            break;
        }
    }
    cout << "\t\t\t\t\t\t二进制结果是:";
    for (; i > -1; i--)
    {
        cout << a[i];
    }
    cout << endl;
}

void SZB(int d)                      //十进制装16进制
{
    int i, j, x = 0;
    int a[1000];
    x = d;
    for (i = 0;; i++)
    {
        a[i] = x % 16;
        x = x / 16;
        if (x == 0)
        {
            break;
        }
    }
    cout << "\t\t\t\t\t\t16进制结果是:";
    for (; i > -1; i--)
    {
        cout << a[i];
    }
    cout << endl;
}

void SZSL(int d)                         //十进制装8进制
{
    int i, j, x = 0;
    int a[1000];
    x = d;
    for (i = 0;; i++)
    {
        a[i] = x % 8;
        x = x / 8;
        if (x == 0)
        {
            break;
        }
    }
    cout << "\t\t\t\t\t\t8进制结果是: " ;
    for (; i > -1; i--)
    {
        cout << a[i];
    }
    cout << endl;
}

int SZ()
{
   
    system("cls");
    cout << endl;
    cout << endl;
    cout << "\t\t\t\t\t\t>>>十进制转其它\n\n\n" << endl;
    cout << endl;
    cout << endl;

    int c;
    cout << "\t\t\t\t\t\t请输入一个十进制数:";
    cin >> c;
    SZE(c);
    SZB(c);
    SZSL(c);
    //
    //
    //
    int s;
    cout << "\n\t\t\t\t\t\t继续使用就输入1,否则就回到上一层0>>>" ;
    cin >> s;
    if (s == 1)
    {
        SZ();
    }
    else if (s == 0) {
        numericalBaseConversion_36();
    }
    return 0;
}
二进制、八进制、十六进制转十进制

long bintodec(const char* pbin)
{
    int ii = 0;
    long result = 0;
    while (pbin[ii] != 0)
    {
        result = result * 2 + (pbin[ii] - '0');
        ii++;
    }
    return result;
}

int EZS()
{
    system("cls");
    cout << endl;
    cout << endl;
    cout << "\t\t\t\t\t\t\t\t     >>>二进制转10进制\n";
    cout << endl;

    
    char str[65];
    memset(str, 0, sizeof(str));
    cout << "\t\t\t\t\t\t请输入一个二进制的字符串:";
    cin >> str;
    cout << "\t\t\t\t\t\t转换为十进制的结果是:" << bintodec(str);
    cout << endl;
    //
    //
    //
    int s;
    cout << "\n\t\t\t\t\t\t继续使用就输入1,否则就回到上一层0>>>" ;
    cin >> s;
    if (s == 1)
    {
        EZS();
    }
    else if (s == 0) {
        QTZSYM();
    }
    return 0;
}

const int Maxn = 1e3 + 2;
int BZS()
{
	system("cls");
	cout << endl;
	cout << endl;
	cout << "\t\t\t\t\t\t\t\t     >>>八进制转10进制\n\n";


	
	char str[Maxn]; // 1234
	cout << "\t\t\t\t\t\t请输入八进制数:";
	cin >> str;
	cout << endl; 
	cout << endl;


	
	int n = 0;
	int i = 0;
	while (str[i] != '\0')
	{
		n = n * 8 + str[i] - '0';
		i++;
	}
	cout << "\t\t\t\t\t\t" << str << "的十进制是:" << n << endl;
	//
	//
	//
	int s;
	cout << "\n\t\t\t\t\t\t继续使用就输入1,否则就回到上一层0>>>" ;
	cin >> s;
	if (s == 1)
	{
		BZS();
	}
	else if (s == 0) {
		QTZSYM();
	}
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS 
#include<stdio.h>
#include<string>
int trans(char* p) {
	int len, sum = 0;
	len = strlen(p);
	for (int i = 0; i < len; i++) {
		if (p[i] >= 'a' && p[i] <= 'f')
			sum = sum + (p[i] - 'a' + 10) * pow(16, len - i - 1);
		else if (p[i] >= 'A' && p[i] <= 'F')
			sum += (p[i] - 'A' + 10) * pow(16, len - i - 1);
		else
			sum += (p[i] - '0') * pow(16, len - i - 1);
	}
	return sum;
}
int SLZS() 
{
	system("cls");
	cout << endl;
	cout << endl;
	cout << "\t\t\t\t\t\t\t\t     >>>16进制转10进制\n\n";


	cout << "\t\t\t\t\t\t请输入一个16进制数:";
	char p[10];
	int num;
	cin >> p;
	num = trans(p);
	cout << "\t\t\t\t\t\t结果:" << num << "\n";
	
	//
	//
	//
	int s;
	cout << "\n\t\t\t\t\t\t继续使用就输入1,否则就回到上一层0>>>" ;
	cin >> s;
	if (s == 1)
	{
		SLZS();
	}
	else if (s == 0) {
		QTZSYM();
	}
	return 0;
}
排列运算
long long A(long long n)              //计算条件&函数的递归
{
	if (n == 0 || n == 1)
		return 1;
	else
		return n * A(n - 1);
}
long long AAA(long long n, long long m)//计算排列
{
	return A(n) / A(n - m);
}

int AA()
{
	system("cls");
	cout << endl;
	cout << endl;
	cout << "\t\t\t\t\t\t\t\t>>>排列\n\n";

	cout << "\t\t\t\t\t\t请输入n/m:(n>m)\n";
	long long n=0, m=0;
	t:
	cin >> n;//输入n和m
	cin >> m;
	if (n>m) 
	{
		long long  a = AAA(n, m);
		cout << "\t\t\t\t\t\t答案" << a;
	}
	else
	{
		cout << "\n\t\t\t\t\t\t条件有错,请重新开始\n";
		Sleep(1000);
		goto t;
	}
	//
	//
	//
	int s;
	cout << "\n\t\t\t\t\t\t继续使用就输入1,否则就回到上一层0>>>" ;
	cin >> s;
	if (s == 1)
	{
		AA();
	}
	else if (s == 0) {
		permutationAndCombination_36(); 
	}
	return 0;
}
//因为数字可能很大所以用long long,需要注意的是n<=20,不然会超范围
组合运算

//我们会发现其实组合和排列的实现几乎一模一样,只要算出阶乘就可以直接套公式了。

long long C(long long n)//计算结成
{
	if (n == 0 || n == 1)
		return 1;
	else
		return n * C(n - 1);
}
long long CCC(long long n, long long m)//计算组合
{
	return C(n) / (C(n - m) * C(m));
}
int CC()
{
	system("cls");
	cout << endl;
	cout << endl;
	cout << "\t\t\t\t\t\t\t\t>>>组合\n";

	long long n=0, m=0;
	a:
	cout << "\t\t\t\t\t\t请输入n/m:(n>m)\n";
	cin >> n;//输入n和m
	cin >> m;
	if (n>m)
	{
		long long  a = CCC(n, m);
		cout << "\t\t\t\t\t\t答案" << a;
	}
	else
	{
		cout << "\n\t\t\t\t\t\t条件有错,请重新开始\n";
		Sleep(1000);
		goto a;
	}
	//
	//
	//
	//
	int s;
	cout << "\n\t\t\t\t\t\t继续使用就输入1,否则就回到上一层0>>>";
	cin >> s;
	if (s == 1)
	{
		CC();
	}
	else if (s == 0) {
		permutationAndCombination_36();
	}
	return 0;
}
//同样n要<=20.
梯形面积

double ti()				//梯形面积
{
	system("cls");
	cout << endl;
	cout << endl;
	cout << "\t\t\t\t\t\t\t\t>>>梯形\n";



	double x,y,z,S;
	cout<<"\t\t\t\t\t\t输入上低、下低"<<endl;
	cout << "\t\t\t\t\t\t";
	cin>>x;
	cout << "\t\t\t\t\t\t";
	cin>>y;
	cout<<"\t\t\t\t\t\t输入高:";
	cin>>z;//高
	S=(x+y)*z/2;
	cout<<"\t\t\t\t\t\t面积:"<<S;
	//
	//
	//
	int s;
	cout << "\n\t\t\t\t\t\t继续使用就输入1,否则就回到上一层0>>>";
		cin>>s;
		if(s==1)
		{
			ti();
		}else if(s==0){
			geometryCalculation_36();
		}
	return S;
}
三角形面积        

double san()
{
	system("cls");
	cout << endl;
	cout << endl;
	cout << "\t\t\t\t\t\t\t\t>>>三角形\n";



	double x,y,S;
	cout<<"\t\t\t\t\t\t输入长和宽"<<endl;
	cout << "\t\t\t\t\t\t";
	cin>>x;
	cout << "\t\t\t\t\t\t";
	cin>>y;
	S=x*y/2;
	cout<<"\t\t\t\t\t\t面积:"<<S;
	//
	//
	//
	int s;
	cout << "\n\t\t\t\t\t\t继续使用就输入1,否则就回到上一层0>>>";
		cin>>s;
		if(s==1)
		{
			san();
		}else if(s==0){
			geometryCalculation_36();
		}
	return S;
}
圆形面积        

double yuan()			//圆形面积
{
	system("cls");
	cout << endl;
	cout << endl;
	cout << "\t\t\t\t\t\t\t\t>>>圆\n";


	double PT=3.1459;
	double r,S;
	cout<<"\t\t\t\t\t\t输入半径:";
	cin>>r;
	S=r*r*PT;
	cout<<"\t\t\t\t\t\t面积:"<<S;
	//
	//
	//
	int s;
	cout << "\n\t\t\t\t\t\t继续使用就输入1,否则就回到上一层0>>>";
		cin>>s;
		if(s==1)
		{
			yuan();
		}else if(s==0){
			geometryCalculation_36();
		}
	return S;
}
长(正)方形面积      
  

double zheng()			//长(正)方形面积
{
	system("cls");
	cout << endl;
	cout << endl;
	cout << "\t\t\t\t\t\t\t\t>>>长(正)方形面积\n";


	double x,y,S;
	cout<<"\t\t\t\t\t\t输入宽、高"<<endl;
	cout << "\t\t\t\t\t\t";
	cin>>x;
	cout << "\t\t\t\t\t\t";
	cin>>y;
	S=x*y;
	cout<<"\t\t\t\t\t\t面积:"<<S;
	//
	//
	//
	int s;
	cout << "\n\t\t\t\t\t\t继续使用就输入1,否则就回到上一层0>>>";
		cin>>s;
		if(s==1)
		{
			zheng();
		}else if(s==0){
			geometryCalculation_36();
		}
	return S;
}
扇形面积

double shan()			//扇形面积
{
	system("cls");
	cout << endl;
	cout << endl;
	cout << "\t\t\t\t\t\t\t\t>>>扇形\n";


	double PT=3.1459;
	double x,r,S;
	cout<<"\t\t\t\t\t\t输入半径:";
	cin>>r;
	cout<<"\t\t\t\t\t\t如果是计算圆心角就输入0,否则就计算弧长输入1"<<endl;
	int e;
	cout << "\t\t\t\t\t\t";
	cin>>e;
	if(e==0){
	cout<<"\t\t\t\t\t\t请继续输入"<<endl;
	cout << "\t\t\t\t\t\t" ;
	cin>>x;
	S=(x*PT*r)/180;
	cout<<"\t\t\t\t\t\t面积:"<<S;
	
	}else if(e==1){
	cout<<"\t\t\t\t\t\t请继续输入"<<endl;
	cin>>x;
	S=(x*r)/2;
	cout<<"\t\t\t\t\t\t面积:"<<S;
	}	
	//
	//
	//
	int s;
	cout << "\n\t\t\t\t\t\t继续使用就输入1,否则就回到上一层0>>>";
		cin>>s;
		if(s==1)
		{
			shan();
		}else if(s==0){
			geometryCalculation_36();
		}
	return S;
}

代码分析:

        此项目的代码是比较臃肿的,代码不够明确、杂乱。函数命名随意,语法凌乱,结构不够清晰,很多代码重复,浪费大量内存空间。诸多问题,说明本人的杂乱,逻辑不够清晰,层次不够分明。

        本人最迟抱着代码能运行的状态编写,第一次对项目的实训。

技术细节

运用函数与函数之间的切换,运用逻辑、层次分列代码。

最后还望大佬们指正、评判。

  • 11
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值