2014年华为上机机试c语言题目和答案
自己code出来的,结果是正确的,但是其中还有很多的优化之处,还请各位大神多多指导。
代码打包: http://download.csdn.net/detail/sxlwzl/6259411
1.字符串过滤 stringFilter
去重过滤,例子:"2 ++ 7"-->"0" //注意:非法运算

ex1.h
#include <stdio.h>#include <stdlib.h>#include <string.h>#include "ex1.h"#include "ex2.h"#include "ex3.h"int main(){ printf("Enter main()\n"); char option;puts("\nex1:");puts("1.字符串过滤 stringFilter");puts("去重过滤,例子:");puts("\"abcdabefe\"-->\"abcdef\"");do{stringFilter();printf("if you want try anohter test, please input 'y' or input 'n'.\n");fflush(stdin);option = getchar();fflush(stdin);}while(option == 'y' || option == 'Y');puts("\nex2:");puts("2.字符串压缩 stringZip");puts("\"aaaabbccccddeeeeef\"-->\"4a2b4c2d5ef\"");do{stringZip();printf("if you want try anohter test, please input 'y' or input 'n'.\n");fflush(stdin);option = getchar();fflush(stdin);}while(option == 'y' || option == 'Y'); puts("\nex3:"); puts("3.表达式,100以内的正整数,加减运算"); puts("\"4 + 7\"-->\"11\""); puts("\"2 - 7\"-->\"-5\""); puts("\"2 ++ 7\"-->\"0\""); do{my_calc();printf("if you want try anohter test, please input 'y' or input 'n'.\n");fflush(stdin);option = getchar();fflush(stdin);}while(option == 'y' || option == 'Y'); return 0;}