Object-oriented programming first winter work

Object-oriented programming first job

This work belongs courses 2020 Object-Oriented Programming
Where the job requires OOD winter operations 1
The target job Install c ++ development environment, complete the quiz, practice questions, and programming problems, and publish blog.
references "C Programming"
----- c language to read Chinese characters
----- Use the command line
----- Characters and Ascii code converter
----- c language compilation process
----- c language pointer concept

Questions and Answers:
If you do not know C ++, please answer the following questions: What do you think C language defects (Where do you think the use is not easily).
A pointer, as a university to be in contact with computer programming practice typing keyboard to see the letters white, personally feel that the c language pointer part is not used more easily, compared to other sections of abstract concepts, pta platform in a job the basic all cases involving the use of an array of pointers will solve the problem, in which the requirements to build spiral square two-dimensional array can be directly applied knowledge to solve practical problems, of course, we want to use the white pointer for the code to solve a square spiral I feel on test machine to test this thing first thought is a two-dimensional array, as well as lianliankan problem according to the topic or two-dimensional array is more convenient, although the pointer is more convenient features c language, the use of still depends on the individual, the individual feels pointers troublesome to point two-dimensional array, used to directly take in the one-dimensional pointer values required for processing in a two-dimensional array (f + x) + y (f assuming that the pointer points to a two-dimensional array, y, x are address constant) obtained at this time only the elements necessary to add * get the value, in terms of simple two-dimensional array of still more popular, reflected in the construction of the letter The value of formal parameters need to enter the number of the address (because they always cause the input values and operating results do not meet the debug example a half-day only to find that pot address) always makes me uncomfortable to look for error (mostly because or vegetables (funny doge)).
II. Recursion, think of this stuff basically think of the Tower of Hanoi applications, multi-use recursion can be applied to the Fibonacci series columns, stairs classical problems. []

Compile:
c design of a procedure referred to as low-level language is not universal invention to solve high-level language syntax close to human habits, because the machine can not directly identify the high-level language compiler software needs to be compiled, the compiler is to convert high-level language into assembly language is converted to binary machine language instruction in line with machine recognition machine, the process involves the replacement characters to delete the unwanted annotation, add files and mark the line number, reading the C language source code, for (# instructions beginning) wherein processing directives, and special symbols generate executable application.

Practice topic:
the practice topic in unfamiliar win + r Enter cmd to open the way DOS panel, not multiple entries in the input cd prerequisite files can not view the path leading to gcc version, and the need to write source code in Notepad file conversion errors need access to exe files, as well as 64-bit windows does not support exe files under 16 conditions leading to not run your file is accessed directly c after the procedure to exe format, and enter the path, the main question should be opened directly with cpp file accompanying generation the exe relevant, indeed, can not solve the resulting system in 64-bit Windows executables can not run under 64-bit Windows environment, as well as unbuilt c operating environment leading to the source can not be converted in the advanced panel cmd environment variables to the appropriate the exe, should be appropriate to build the file path path environment inserted into the corresponding system variable in this computer, not constructed corresponding include, lib variables, and execution of the program can not be present after the completion of the environment can not be constructed to convert a source program executable program exe leading to not run (without adding the Path system variable, lib, include variable), as well as experience with Baidu You mentioned Windows default generate a.exe contrary still generate an executable program with the same name c source.



编程题:
编程要求:编写一个程序,输入满足以下语法要求的一段文字,输出运行后的结果。
经过查阅知道由汉字可以是两个ascii码组成,而字符仅占一字节与一ascii码所占据空间等价,将汉字转换为字符数组进行储存调取相关有用字符数组中的几个便可知道进行什么操作,先创建4个字符数组针对题目要求,开辟空间足够大容纳汉字,后对第一行字符数组16,17,第二三行字符数组6,7,8,9,11,12重点关注,提取ascii码,与字母,数字对应的acsii码可能进行加减后再进行转换尚且可以有效换算出结果不同此时得到的ascii码并没有太多用处,对于处理汉字的ascii码不大好使,而且经过初步在Devc++上针对汉字“一”的转换得到“-46 -49”后放到网页版ascii码转换器进行转换后得到结果不同。

参考C程序设计数组章节内容strcmp函数用法,字符串比较的规则是将两个字符串自左向右逐个相比,若两字符串相等则函数值为0,其余为正反数,则只需看看输入字符串与“钱包 增加 四”“此类的函数值是否为0即可(总计40种)考虑到一次性判断整个字符串存在不能找到程序停止的指令,故需要对第一行表明钱包的初始钱数单独考虑,后面输入由于涉及何时停止程序,把第一个输入内容独立出来考虑对输入的字符串是否是“看看”是的话终止交易,不是继续运行,针对计算符号和数字单独分析。
代码部分:

include <stdio.h>

include <string.h>

int main(void)
{
int sumcomputer(char num[20]);
int how(char how[20]);
void change(int number);
int sum,witness,first,second;
char a[20],b[20],c[20],d[20];
scanf("%s %s %s %s",a,b,c,d);
sum=sumcomputer(d);
while(1)
{
scanf("%s ",a);
if(strcmp(a,"看看")==0)break;
scanf("%s %s",b,c);
witness=how(b);
if(witness)sum+=sumcomputer(c);
else sum-=sumcomputer(c);
}
if(sum<=10)change(sum);
else if(sum>99)printf("但凡有一粒头孢");
else
{
second=sum%10;
first=(sum/10)%10;
change(first);
printf("十");
change(second);
}
}
int sumcomputer(char num[20])
{
if(strcmp(num,"零")==0)return 0;
else if(strcmp(num,"一")==0)return 1;
else if(strcmp(num,"二")==0)return 2;
else if(strcmp(num,"三")==0)return 3;
else if(strcmp(num,"四")==0)return 4;
else if(strcmp(num,"五")==0)return 5;
else if(strcmp(num,"六")==0)return 6;
else if(strcmp(num,"七")==0)return 7;
else if(strcmp(num,"八")==0)return 8;
else if(strcmp(num,"九")==0)return 9;
else if(strcmp(num,"十")==0)return 10;
}
void change(int number)
{
if(number==0)printf("零");
else if(number==1)printf("一");
else if(number==2)printf("二");
else if(number==3)printf("三");
else if(number==4)printf("四");
else if(number==5)printf("五");
else if(number==6)printf("六");
else if(number==7)printf("七");
else if(number==8)printf("八");
else if(number==9)printf("九");
else if(number==10)printf("十");
}
int how(char how[20])
{
if(strcmp(how,"减少")==0)return 0;
else return 1;
}
其中how函数用于判断所需要进行的操作,change函数用于控制输出,sumcomputer函数用于计算sum的值用于输出结果。
实践结果:


Guess you like

Origin www.cnblogs.com/pekkasuper/p/12220589.html