zoukankan      html  css  js  c++  java
  • 2020寒假作业-1

    这个作业属于哪个课程 2020年面向对象程序设计
    这个作业要求在哪里 面向对象程序设计寒假作业1
    这个作业的目标 1.安装C++开发环境 2.完成问答题、实践题及编程题 3.发布博客
    作业正文 https://www.cnblogs.com/ying-hua/p/12222477.html
    其他参考文献 https://jingyan.baidu.com/article/b2c186c81e79a6c46ef6ffd1.html

    一.问答题

    1.c语言的缺陷:

    我不了解c++,学习c语言到现在的确遇到一些不顺手的地方。例如:输入或输出不同类型的变量时要用不同的格式符,比如%d %lf。有时整个程序都要修改,比较麻烦。最烦恼的地方就是在程序某些地方写错的时候不会编译错误,比如把%d写成%n,或者忘记加地址符&,这类错误就难以找到。

    2.c语言的编译过程:

    (1)进行编译预处理:对程序中的伪指令和特殊符号进行处理。
    (2)编译:将经过预处理之后的程序转换成特定汇编代码。
    (3)汇编:将汇编代码转化为机器码,产生目标文件。
    (4)连接:连接多个目标文件和库文件,产生可执行文件。

    二.实践题

    1.查看c++编译器版本

    打开devc++,就在右上角,如图

    2.使用命令行编译一份c语言代码

    由于不懂什么事命令行,我搜索到了如下网址,并按他的方法操作
    https://jingyan.baidu.com/article/b2c186c81e79a6c46ef6ffd1.html
    然而里面有错误,无论如何我都找不到vsvarsall.bat 后来看到图片中是vcvarsall.bat
    于是我就找到vcvarsall.bat的目录,模仿图片中的代码写,居然成功了

    然后继续模仿图片代码,成功生成exe文件
    但是我输入数据按了回车后程序就退出了,我还没来得及看清答案QAQ
    于是我就在命令行中直接运行程序,终于成功了

    三.编程题(c语言)

    问题分解

    1.如何辨别汉字?

    汉字本质上是字符串,经过查阅资料,了解c语言中的strcmp函数可以比较字符串,于是所有的汉字我都用以下的方法辨别。
    strcmp(str,"整数")==0

    2.如何让计算机知道需要定义、计算还是输出?

    我用了类似模拟题的方法做的:
    程序每行第一个字符串只能是“整数”、“看看”或一个变量

    • 如果第一个字符串是关键字或数字对应的汉字则输入不合法
    • 如果字符串是“整数”,就再读取三个字符串并判断合法性
    • 如果字符串是“看看”,就再读取一个字符串并判断合法性
    • 如果不是以上三种情况,就将字符串作为一个变量名

    3.将汉字变量与英文变量一一对应

    输入的汉字变量名不能作为程序的变量名,那么如何使输入的汉字变量对应程序中的一个变量呢?
    这里我用了结构体数据类型,定义了一个结构体,并用如下方式初始化

    struct Var{
    		int engv;          //英文变量 
    		char chi[20];      //汉字变量 
    	};
    struct Var var[100]={0,""};
    

    4.汉字与数字相互转换

    我定义了两个如下的函数来实现该功能

    int to_num(char num[]) //汉字转数字
    {
        if(strcmp(num,"零")==0)return 0;
        if(strcmp(num,"一")==0)return 1;
    }
    void print_chi(int engv) //输出汉字
    {
        switch(engv){
        case 0:printf("零
    ");break;
        case 1:printf("一
    ");break;
        }
    }
    

    5.合法性判断

    用户输入的数据可能不合法,有如下几种情况

    • 将关键字或数字对应的汉字作为变量名
    • 关键字打错
    • 输入的数字不合法(二十一写成二一就不行)
    • 重复定义变量
    • 还未定义变量就做运算或输出
    • 做增加运算时超过99
    • 做减少运算时小于0
      遇到以上几种情况时输出错误提示

    6.如何定义变量、运算和输出?

    定义

    定义变量时将汉字变量名存入结构体数组中,并对其对应的英文变量赋值

    运算

    读取到“增加”时将对应英文变量加上汉字对应的数值
    读取到“减少”时将对应英文变量减去汉字对应的数值

    输出

    读取到“看看”时输出数值对应的汉字

    完整代码(v1.0)

    #include<stdio.h>
    #include<math.h>
    #include<stdlib.h>
    #include<string.h>
    struct Var{
    		int engv;          //英文变量 
    		char chi[20];      //汉字变量 
    	};
    struct Var var[100]={0,""};
    void error()
    {
    	printf("你写错啦!!!");
    }
    int op_legal(char op[])
    {
    	if(strcmp(op,"等于")==0||strcmp(op,"增加")==0||strcmp(op,"减少")==0||
    	strcmp(op,"零")==0||strcmp(op,"一")==0||strcmp(op,"二")==0||
    	strcmp(op,"三")==0||strcmp(op,"四")==0||strcmp(op,"五")==0||
    	strcmp(op,"六")==0||strcmp(op,"七")==0||strcmp(op,"八")==0||
    	strcmp(op,"九")==0||strcmp(op,"十")==0||strcmp(op,"十一")==0||strcmp(op,"十二")==0||
    	strcmp(op,"十三")==0||strcmp(op,"十四")==0||strcmp(op,"十五")==0||
    	strcmp(op,"十六")==0||strcmp(op,"十七")==0||strcmp(op,"十八")==0||
    	strcmp(op,"十九")==0||strcmp(op,"二十")==0||strcmp(op,"二十一")==0||
    	strcmp(op,"二十二")==0||strcmp(op,"二十三")==0||strcmp(op,"二十四")==0||
    	strcmp(op,"二十五")==0||strcmp(op,"二十六")==0||strcmp(op,"二十七")==0||
    	strcmp(op,"二十八")==0||strcmp(op,"二十九")==0||strcmp(op,"三十")==0||strcmp(op,"三十一")==0||
    	strcmp(op,"三十二")==0||strcmp(op,"三十三")==0||strcmp(op,"三十四")==0||
    	strcmp(op,"三十五")==0||strcmp(op,"三十六")==0||strcmp(op,"三十七")==0||
    	strcmp(op,"三十八")==0||strcmp(op,"三十九")==0||strcmp(op,"四十")==0||strcmp(op,"四十一")==0||
    	strcmp(op,"四十二")==0||strcmp(op,"四十三")==0||strcmp(op,"四十四")==0||
    	strcmp(op,"四十五")==0||strcmp(op,"四十六")==0||strcmp(op,"四十七")==0||
    	strcmp(op,"四十八")==0||strcmp(op,"四十九")==0||strcmp(op,"五十")==0||strcmp(op,"五十一")==0||
    	strcmp(op,"五十二")==0||strcmp(op,"五十三")==0||strcmp(op,"五十四")==0||
    	strcmp(op,"五十五")==0||strcmp(op,"五十六")==0||strcmp(op,"五十七")==0||
    	strcmp(op,"五十八")==0||strcmp(op,"五十九")==0||strcmp(op,"六十")==0||strcmp(op,"六十一")==0||
    	strcmp(op,"六十二")==0||strcmp(op,"六十三")==0||strcmp(op,"六十四")==0||
    	strcmp(op,"六十五")==0||strcmp(op,"六十六")==0||strcmp(op,"六十七")==0||
    	strcmp(op,"六十八")==0||strcmp(op,"六十九")==0||strcmp(op,"七十")==0||strcmp(op,"七十一")==0||
    	strcmp(op,"七十二")==0||strcmp(op,"七十三")==0||strcmp(op,"七十四")==0||
    	strcmp(op,"七十五")==0||strcmp(op,"七十六")==0||strcmp(op,"七十七")==0||
    	strcmp(op,"七十八")==0||strcmp(op,"七十九")==0||strcmp(op,"八十")==0||strcmp(op,"八十一")==0||
    	strcmp(op,"八十二")==0||strcmp(op,"八十三")==0||strcmp(op,"八十四")==0||
    	strcmp(op,"八十五")==0||strcmp(op,"八十六")==0||strcmp(op,"八十七")==0||
    	strcmp(op,"八十八")==0||strcmp(op,"八十九")==0||strcmp(op,"九十")==0||strcmp(op,"九十一")==0||
    	strcmp(op,"九十二")==0||strcmp(op,"九十三")==0||strcmp(op,"九十四")==0||
    	strcmp(op,"九十五")==0||strcmp(op,"九十六")==0||strcmp(op,"九十七")==0||
    	strcmp(op,"九十八")==0||strcmp(op,"九十九")==0)
    		return 0;
    	return 1;
    }
    int var_legal(char vari[])
    {
    	int i;
    	if(strcmp(vari,"整数")==0||strcmp(vari,"等于")==0||
    	strcmp(vari,"增加")==0||strcmp(vari,"减少")==0||strcmp(vari,"看看")==0)
    		return 0;
    	for(i=0;strlen(var[i].chi)!=0;i++)
    		if(strcmp(vari,var[i].chi)==0)  //变量已被定义过 
    			return 0;
    	return 1;
    }
    int num_legal(char num[])
    {
    	if(strcmp(num,"零")==0||strcmp(num,"一")==0||strcmp(num,"二")==0||
    	strcmp(num,"三")==0||strcmp(num,"四")==0||strcmp(num,"五")==0||
    	strcmp(num,"六")==0||strcmp(num,"七")==0||strcmp(num,"八")==0||
    	strcmp(num,"九")==0||strcmp(num,"十")==0||strcmp(num,"十一")==0||strcmp(num,"十二")==0||
    	strcmp(num,"十三")==0||strcmp(num,"十四")==0||strcmp(num,"十五")==0||
    	strcmp(num,"十六")==0||strcmp(num,"十七")==0||strcmp(num,"十八")==0||
    	strcmp(num,"十九")==0||strcmp(num,"二十")==0||strcmp(num,"二十一")==0||
    	strcmp(num,"二十二")==0||strcmp(num,"二十三")==0||strcmp(num,"二十四")==0||
    	strcmp(num,"二十五")==0||strcmp(num,"二十六")==0||strcmp(num,"二十七")==0||
    	strcmp(num,"二十八")==0||strcmp(num,"二十九")==0||strcmp(num,"三十")==0||strcmp(num,"三十一")==0||
    	strcmp(num,"三十二")==0||strcmp(num,"三十三")==0||strcmp(num,"三十四")==0||
    	strcmp(num,"三十五")==0||strcmp(num,"三十六")==0||strcmp(num,"三十七")==0||
    	strcmp(num,"三十八")==0||strcmp(num,"三十九")==0||strcmp(num,"四十")==0||strcmp(num,"四十一")==0||
    	strcmp(num,"四十二")==0||strcmp(num,"四十三")==0||strcmp(num,"四十四")==0||
    	strcmp(num,"四十五")==0||strcmp(num,"四十六")==0||strcmp(num,"四十七")==0||
    	strcmp(num,"四十八")==0||strcmp(num,"四十九")==0||strcmp(num,"五十")==0||strcmp(num,"五十一")==0||
    	strcmp(num,"五十二")==0||strcmp(num,"五十三")==0||strcmp(num,"五十四")==0||
    	strcmp(num,"五十五")==0||strcmp(num,"五十六")==0||strcmp(num,"五十七")==0||
    	strcmp(num,"五十八")==0||strcmp(num,"五十九")==0||strcmp(num,"六十")==0||strcmp(num,"六十一")==0||
    	strcmp(num,"六十二")==0||strcmp(num,"六十三")==0||strcmp(num,"六十四")==0||
    	strcmp(num,"六十五")==0||strcmp(num,"六十六")==0||strcmp(num,"六十七")==0||
    	strcmp(num,"六十八")==0||strcmp(num,"六十九")==0||strcmp(num,"七十")==0||strcmp(num,"七十一")==0||
    	strcmp(num,"七十二")==0||strcmp(num,"七十三")==0||strcmp(num,"七十四")==0||
    	strcmp(num,"七十五")==0||strcmp(num,"七十六")==0||strcmp(num,"七十七")==0||
    	strcmp(num,"七十八")==0||strcmp(num,"七十九")==0||strcmp(num,"八十")==0||strcmp(num,"八十一")==0||
    	strcmp(num,"八十二")==0||strcmp(num,"八十三")==0||strcmp(num,"八十四")==0||
    	strcmp(num,"八十五")==0||strcmp(num,"八十六")==0||strcmp(num,"八十七")==0||
    	strcmp(num,"八十八")==0||strcmp(num,"八十九")==0||strcmp(num,"九十")==0||strcmp(num,"九十一")==0||
    	strcmp(num,"九十二")==0||strcmp(num,"九十三")==0||strcmp(num,"九十四")==0||
    	strcmp(num,"九十五")==0||strcmp(num,"九十六")==0||strcmp(num,"九十七")==0||
    	strcmp(num,"九十八")==0||strcmp(num,"九十九")==0)
    		return 1;
    	return 0;
    }
    int equal_legal(char equal[])
    {
    	if(strcmp(equal,"等于")==0)
    		return 1;
    	return 0;
    }
    int to_num(char num[])
    {
    	if(strcmp(num,"零")==0)return 0;
    	if(strcmp(num,"一")==0)return 1;
    	if(strcmp(num,"二")==0)return 2;
    	if(strcmp(num,"三")==0)return 3;
    	if(strcmp(num,"四")==0)return 4;
    	if(strcmp(num,"五")==0)return 5;
    	if(strcmp(num,"六")==0)return 6;
    	if(strcmp(num,"七")==0)return 7;
    	if(strcmp(num,"八")==0)return 8;
    	if(strcmp(num,"九")==0)return 9;
    	if(strcmp(num,"十")==0)return 10;
    	if(strcmp(num,"十一")==0)return 11;
    	if(strcmp(num,"十二")==0)return 12;
    	if(strcmp(num,"十三")==0)return 13;
    	if(strcmp(num,"十四")==0)return 14;
    	if(strcmp(num,"十五")==0)return 15;
    	if(strcmp(num,"十六")==0)return 16;
    	if(strcmp(num,"十七")==0)return 17;
    	if(strcmp(num,"十八")==0)return 18;
    	if(strcmp(num,"十九")==0)return 19;
    	if(strcmp(num,"二十")==0)return 20;
    	if(strcmp(num,"二十一")==0)return 21;
    	if(strcmp(num,"二十二")==0)return 22;
    	if(strcmp(num,"二十三")==0)return 23;
    	if(strcmp(num,"二十四")==0)return 24;
    	if(strcmp(num,"二十五")==0)return 25;
    	if(strcmp(num,"二十六")==0)return 26;
    	if(strcmp(num,"二十七")==0)return 27;
    	if(strcmp(num,"二十八")==0)return 28;
    	if(strcmp(num,"二十九")==0)return 29;
    	if(strcmp(num,"三十")==0)return 30;
    	if(strcmp(num,"三十一")==0)return 31;
    	if(strcmp(num,"三十二")==0)return 32;
    	if(strcmp(num,"三十三")==0)return 33;
    	if(strcmp(num,"三十四")==0)return 34;
    	if(strcmp(num,"三十五")==0)return 35;
    	if(strcmp(num,"三十六")==0)return 36;
    	if(strcmp(num,"三十七")==0)return 37;
    	if(strcmp(num,"三十八")==0)return 38;
    	if(strcmp(num,"三十九")==0)return 39;
    	if(strcmp(num,"四十")==0)return 40;
    	if(strcmp(num,"四十一")==0)return 41;
    	if(strcmp(num,"四十二")==0)return 42;
    	if(strcmp(num,"四十三")==0)return 43;
    	if(strcmp(num,"四十四")==0)return 44;
    	if(strcmp(num,"四十五")==0)return 45;
    	if(strcmp(num,"四十六")==0)return 46;
    	if(strcmp(num,"四十七")==0)return 47;
    	if(strcmp(num,"四十八")==0)return 48;
    	if(strcmp(num,"四十九")==0)return 49;
    	if(strcmp(num,"五十")==0)return 50;
    	if(strcmp(num,"五十一")==0)return 51;
    	if(strcmp(num,"五十二")==0)return 52;
    	if(strcmp(num,"五十三")==0)return 53;
    	if(strcmp(num,"五十四")==0)return 54;
    	if(strcmp(num,"五十五")==0)return 55;
    	if(strcmp(num,"五十六")==0)return 56;
    	if(strcmp(num,"五十七")==0)return 57;
    	if(strcmp(num,"五十八")==0)return 58;
    	if(strcmp(num,"五十九")==0)return 59;
    	if(strcmp(num,"六十")==0)return 60;
    	if(strcmp(num,"六十一")==0)return 61;
    	if(strcmp(num,"六十二")==0)return 62;
    	if(strcmp(num,"六十三")==0)return 63;
    	if(strcmp(num,"六十四")==0)return 64;
    	if(strcmp(num,"六十五")==0)return 65;
    	if(strcmp(num,"六十六")==0)return 66;
    	if(strcmp(num,"六十七")==0)return 67;
    	if(strcmp(num,"六十八")==0)return 68;
    	if(strcmp(num,"六十九")==0)return 69;
    	if(strcmp(num,"七十")==0)return 70;
    	if(strcmp(num,"七十一")==0)return 71;
    	if(strcmp(num,"七十二")==0)return 72;
    	if(strcmp(num,"七十三")==0)return 73;
    	if(strcmp(num,"七十四")==0)return 74;
    	if(strcmp(num,"七十五")==0)return 75;
    	if(strcmp(num,"七十六")==0)return 76;
    	if(strcmp(num,"七十七")==0)return 77;
    	if(strcmp(num,"七十八")==0)return 78;
    	if(strcmp(num,"七十九")==0)return 79;
    	if(strcmp(num,"八十")==0)return 80;
    	if(strcmp(num,"八十一")==0)return 81;
    	if(strcmp(num,"八十二")==0)return 82;
    	if(strcmp(num,"八十三")==0)return 83;
    	if(strcmp(num,"八十四")==0)return 84;
    	if(strcmp(num,"八十五")==0)return 85;
    	if(strcmp(num,"八十六")==0)return 86;
    	if(strcmp(num,"八十七")==0)return 87;
    	if(strcmp(num,"八十八")==0)return 88;
    	if(strcmp(num,"八十九")==0)return 89;
    	if(strcmp(num,"九十")==0)return 90;
    	if(strcmp(num,"九十一")==0)return 91;
    	if(strcmp(num,"九十二")==0)return 92;
    	if(strcmp(num,"九十三")==0)return 93;
    	if(strcmp(num,"九十四")==0)return 94;
    	if(strcmp(num,"九十五")==0)return 95;
    	if(strcmp(num,"九十六")==0)return 96;
    	if(strcmp(num,"九十七")==0)return 97;
    	if(strcmp(num,"九十八")==0)return 98;
    	if(strcmp(num,"九十九")==0)return 99;
    }
    int is_defined(char vari[])
    {
    	int i;
    	for(i=0;strlen(var[i].chi)!=0;i++)
    		if(strcmp(vari,var[i].chi)==0)
    			return 1;
    	return 0;
    }
    void print_chi(int engv)
    {
    	switch(engv){
    		case 0:printf("零
    ");break;
    		case 1:printf("一
    ");break;
    		case 2:printf("二
    ");break;
    		case 3:printf("三
    ");break;
    		case 4:printf("四
    ");break;
    		case 5:printf("五
    ");break;
    		case 6:printf("六
    ");break;
    		case 7:printf("七
    ");break;
    		case 8:printf("八
    ");break;
    		case 9:printf("九
    ");break;
    		case 10:printf("十
    ");break;
    		case 11:printf("十一
    ");break;
    		case 12:printf("十二
    ");break;
    		case 13:printf("十三
    ");break;
    		case 14:printf("十四
    ");break;
    		case 15:printf("十五
    ");break;
    		case 16:printf("十六
    ");break;
    		case 17:printf("十七
    ");break;
    		case 18:printf("十八
    ");break;
    		case 19:printf("十九
    ");break;
    		case 20:printf("二十
    ");break;
    		case 21:printf("二十一
    ");break;
    		case 22:printf("二十二
    ");break;
    		case 23:printf("二十三
    ");break;
    		case 24:printf("二十四
    ");break;
    		case 25:printf("二十五
    ");break;
    		case 26:printf("二十六
    ");break;
    		case 27:printf("二十七
    ");break;
    		case 28:printf("二十八
    ");break;
    		case 29:printf("二十九
    ");break;
    		case 30:printf("三十
    ");break;
    		case 31:printf("三十一
    ");break;
    		case 32:printf("三十二
    ");break;
    		case 33:printf("三十三
    ");break;
    		case 34:printf("三十四
    ");break;
    		case 35:printf("三十五
    ");break;
    		case 36:printf("三十六
    ");break;
    		case 37:printf("三十七
    ");break;
    		case 38:printf("三十八
    ");break;
    		case 39:printf("三十九
    ");break;
    		case 40:printf("四十
    ");break;
    		case 41:printf("四十一
    ");break;
    		case 42:printf("四十二
    ");break;
    		case 43:printf("四十三
    ");break;
    		case 44:printf("四十四
    ");break;
    		case 45:printf("四十五
    ");break;
    		case 46:printf("四十六
    ");break;
    		case 47:printf("四十七
    ");break;
    		case 48:printf("四十八
    ");break;
    		case 49:printf("四十九
    ");break;
    		case 50:printf("五十
    ");break;
    		case 51:printf("五十一
    ");break;
    		case 52:printf("五十二
    ");break;
    		case 53:printf("五十三
    ");break;
    		case 54:printf("五十四
    ");break;
    		case 55:printf("五十五
    ");break;
    		case 56:printf("五十六
    ");break;
    		case 57:printf("五十七
    ");break;
    		case 58:printf("五十八
    ");break;
    		case 59:printf("五十九
    ");break;
    		case 60:printf("六十
    ");break;
    		case 61:printf("六十一
    ");break;
    		case 62:printf("六十二
    ");break;
    		case 63:printf("六十三
    ");break;
    		case 64:printf("六十四
    ");break;
    		case 65:printf("六十五
    ");break;
    		case 66:printf("六十六
    ");break;
    		case 67:printf("六十七
    ");break;
    		case 68:printf("六十八
    ");break;
    		case 69:printf("六十九
    ");break;
    		case 70:printf("七十
    ");break;
    		case 71:printf("七十一
    ");break;
    		case 72:printf("七十二
    ");break;
    		case 73:printf("七十三
    ");break;
    		case 74:printf("七十四
    ");break;
    		case 75:printf("七十五
    ");break;
    		case 76:printf("七十六
    ");break;
    		case 77:printf("七十七
    ");break;
    		case 78:printf("七十八
    ");break;
    		case 79:printf("七十九
    ");break;
    		case 80:printf("八十
    ");break;
    		case 81:printf("八十一
    ");break;
    		case 82:printf("八十二
    ");break;
    		case 83:printf("八十三
    ");break;
    		case 84:printf("八十四
    ");break;
    		case 85:printf("八十五
    ");break;
    		case 86:printf("八十六
    ");break;
    		case 87:printf("八十七
    ");break;
    		case 88:printf("八十八
    ");break;
    		case 89:printf("八十九
    ");break;
    		case 90:printf("九十
    ");break;
    		case 91:printf("九十一
    ");break;
    		case 92:printf("九十二
    ");break;
    		case 93:printf("九十三
    ");break;
    		case 94:printf("九十四
    ");break;
    		case 95:printf("九十五
    ");break;
    		case 96:printf("九十六
    ");break;
    		case 97:printf("九十七
    ");break;
    		case 98:printf("九十八
    ");break;
    		case 99:printf("九十九
    ");break;
    	}
    }
    void look(char vari[])
    {
    	int i;
    	for(i=0;strlen(var[i].chi)!=0;i++)
    		if(strcmp(vari,var[i].chi)==0){		
    			print_chi(var[i].engv);
    			break;
    		}
    }
    int compute_legal(char compute[])
    {
    	if(strcmp(compute,"增加")==0||strcmp(compute,"减少")==0)
    		return 1;
    	return 0;
    }
    void computef(char vari[],char com[],char num[])
    {
    	int i;
    	if(strcmp(com,"增加")==0){
    		for(i=0;strlen(var[i].chi)!=0;i++)
    			if(strcmp(vari,var[i].chi)==0){
    				if((var[i].engv+to_num(num))>=100)
    					printf("增加的数值过大
    ");
    				else 
    					var[i].engv+=to_num(num);
    				break;
    			}
    	}
    	else{
    		for(i=0;strlen(var[i].chi)!=0;i++)
    			if(strcmp(vari,var[i].chi)==0){
    				if((var[i].engv-to_num(num))<0)
    					printf("减少的数值过大
    ");
    				else 
    					var[i].engv-=to_num(num);
    				break;
    			}
    	}
    }
    int main()
    {
    	int i=0,j;
    	char op[10],vari[10],num[10],compute[10],equal[10];
    	while(1){
    		scanf("%s",op);
    		if(op_legal(op)==0)
    			error(); 
    		else{
    			if(strcmp(op,"整数")==0){
    				scanf("%s%s%s",vari,equal,num);
    				if(var_legal(vari)==0||num_legal(num)==0||equal_legal(equal)==0)
    					error();
    				else{
    					var[i].engv=to_num(num);
    					strcpy(var[i].chi,vari);
    					i++;
    				}
    			}
    			else if(strcmp(op,"看看")==0){
    				scanf("%s",vari);
    				if(is_defined(vari)==0)
    					error();
    				else
    					look(vari);
    			}
    			else{       //计算 
    				if(is_defined(op)==0)
    					error(); 
    				else{
    					scanf("%s%s",compute,num);
    					if(compute_legal(compute)==0||num_legal(num)==0)
    						error();
    					else{
    						computef(op,compute,num);
    					}
    				}
    			}
    		}
    	}
    	return 0;
    }
    

    原谅我的代码过于冗长QAQ
    修改后的代码见作业二

  • 相关阅读:
    联想yoga table2 1371f 进入bios 的巧妙方法
    vs开发nodejs api文档生成神器-apidoc
    Android中文乱码彻底解决
    android图片处理方法(不断收集中)
    【Android开发】完美解决Android完全退出程序
    android自动打包方法(ant+proguard+签名)
    Android 访问权限设置记录-存档留着有用!
    [安卓开发]App Widget开发入门指导
    Android蓝牙操作笔记
    android 基于百度地图api开发定位以及获取详细地址
  • 原文地址:https://www.cnblogs.com/ying-hua/p/12222477.html
Copyright © 2011-2022 走看看