分享
分享赚钱 收藏 举报 版权申诉 / 33

类型浙大计算机学院考研复试上机试题.doc

  • 上传人:weiwoduzun
  • 文档编号:2672733
  • 上传时间:2018-09-24
  • 格式:DOC
  • 页数:33
  • 大小:118KB
  • 配套讲稿:

    如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

    特殊限制:

    部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

    关 键  词:
    浙大计算机学院考研复试上机试题.doc
    资源描述:

    1、浙江大学计算机复试上机 2005-2007(由林子整理 QQ:170479150) 2005 年浙江大学计算机学院考研复试上机试题及参考答案(1/5) 第一题:A+B(10 分) 结题题目要求:读入两个小于 100 的正整数 A 和 B,计算 A+B。需要注意的是:A 和 B 的每一位数字由对应的英文单词给出。输入格式:测试输入包含若干测试用例,每个测试用例占一行,格式为“A + B =“,相邻两字符串有一个空格间隔。当 A 和 B 同时为 0 时输入结束,相应的结果不要输出。输出格式:对每个测试用例输出 1 行,即 A+B 的值。输入样例:one + two =three four + fi

    2、ve six =zero seven + eight nine =zero + zero =输出样例:39096#include #include #include #include int main(void)const char data126 = “zero“, “one“, “two“, “three“, “four“,“five“, “six“, “seven“, “eight“, “nine“, “+“, “=“;unsigned a, b; /* 转换后的表达式参数,如 a+b(123+456) */unsigned i, j, k; /* 临时变量,作为下标 */char st

    3、r100; /* 输入字符串,足够大容量 */char temp6; /* 临时字符串,用于检索数字,如“one“-1 */char result30; /* 转换后的表达式参数,如“123+456=“ */doa = b = i = j = k = 0; /* 初始化变量 */memset(str, 0, sizeof(str);memset(temp, 0, sizeof(temp);memset(result, 0, sizeof(result);gets(str); /* 获取输入字符串,不能使用 scanf,因为有空格 */for(i=0, k=0; i 0 )。下面列出了 N 天的

    4、记录。每天的记录在第一行给出记录的条目数 M ( 0 ),下面是 M 行,每行的格式为证件号码 签到时间 签离时间其中时间按“小时: 分钟:秒钟”(各占 2 位)给出,证件号码是长度不超过 15 的字符串。输出格式:对每一天的记录输出 1 行,即当天开门和关门人的证件号码,中间用 1空格分隔。注意:在裁判的标准测试输入中,所有记录保证完整,每个人的签到时间在签离时间之前,且没有多人同时签到或者签离的情况。输入样例:31ME3021112225321 00:00:00 23:59:592EE301218 08:05:35 20:56:35MA301134 12:35:45 21:40:423CS

    5、301111 15:30:28 17:00:10SC3021234 08:00:00 11:25:25CS301133 21:45:00 21:58:40输出样例:ME3021112225321 ME3021112225321EE301218 MA301134SC3021234 CS301133#include #include #include typedef structchar id16; /* 证件号码长度不超过 15 位 */char cometime9; /* 时间格式 00:00:00 */char leavetime9; /* 时间格式 00:00:00 */Record;in

    6、t main()int N, M, i; /* 记录的总天数 N,每天记录的条目数 M */Record *pTimeList;/* 记录该天出入人员的证件号码、进入时间、离开时间 */int first, last; /* 记录每天开门的人和关门的人 */scanf(“%d“, /* 读入记录的总天数 */while(N-)scanf(“%d“, /* 读入该天的进出人员数 */pTimeList = (Record *)malloc(M*sizeof(Record);for(i=0,first=0,last=0; i 0 )first = i;if( strcmp( pTimeListla

    7、st.leavetime, pTimeListi.leavetime) #include #include typedef structchar id21; /* 准考证号(= G) /* 如果考生上线则记录下来 */n+; /* 否则不予记录,便于排序 */for(i=0; i pStuinfok.score)k = j;tmp = pStuinfok;pStuinfok = pStuinfoi;pStuinfoi = tmp;for(i=0; i 0)c = b;tmp = pStuinfoa;pStuinfoa = pStuinfoc;pStuinfoc = tmp;printf(“%d

    8、n“,n); /* 排序完毕,按照要求输出,上线人数 */for(i=0; i#include #include int main()long int K, last; /* 输入数据个数 K MaxSum) /* 输入含有正数时,忽略最大子序列中首尾 0 的影响 */MaxSum = ThisSum;/* 更新 MaxSum */if( MaxSum TmpMaxSum ) /* 最大值更新时,更新最大子序列最后的数字 */ /* 保证最大子序列起始位置在输入串的最前面 */TmpMaxSum = MaxSum;last = index;if( ThisSum = 0; index- )Tm

    9、pMaxSum += pListindex;if(TmpMaxSum = MaxSum)break;if( MaxSum #includeusing namespace std;int n, visited1024;vector connect(1024,vector(1024);int dfs(int a)int i;visiteda=1;for(i=1;inumtown n = numtown;for(i=1;iab;connectab = connectba = 1;for(j=1;jab;connectab = connectba = 1;for(i=1;i#include int m

    10、ain(void)unsigned int a, b, k;unsigned char ch150, ch250;doscanf(“%d %d %d“, if( a=0sprintf(ch1, “%d“, a); sprintf(ch2, “%d“, b);strrev(ch1);strrev(ch2);if(strlen(ch1)#include int main(void)unsigned N, score, num, i;unsigned pList1000;doscanf(“%d“,if(N=0) break;for(i=0;i#include #include #define N 2

    11、5int IsPrime(int n)int i;if(n= 0; -i)op1Listi + num2 - num1 = op1Listi;op1Listi = 0;if(num1 num2)for(i = num2; i = 0; -i)op2List i + num1 - num2 = op2Listi;op2Listi = 0;cnt = (num1 num2) ? num1 : num2; /* cnt 为两个火星数的较大位数,便于确定输出位数 */for( index=0, i=cnt; i=0 ; i-, index+ )num = op1Listi + op2Listi + O

    12、utputListindex;if( num - PrimeListindex = 0 )OutputListindex = num - PrimeListindex;OutputListindex+1+;if( index + 1 cnt ) cnt+; /* 最高位进位 */elseOutputListindex = num;while( OutputListcnt=0 /* omit leading zeros */for( ; cnt =0 ; cnt- )printf(“%d%c“, OutputListcnt, (cnt=0)?n:,);while(1);return 0; 200

    13、6 年浙江大学计算机学院考研复试上机试题及参考答案(4/5) 第 4 题:简单计算器( 7 分)题目要求:读入一个只包含 +, -, *, / 的正整数计算表达式,计算该表达式的值。输入格式:测试输入包含若干测试用例,每个测试用例占一行,每行不超过 80 个字符,整数和运算符之间用一个空格分隔。没有非法表达式。当一行中只有 0 时输入结束,相应的结果不要输出。输出格式:对每个测试用例输出 1 行,即该表达式的值,精确到小数点后 2 位。输入样例:1 + 24 + 2 * 5 - 7 / 110输出样例:3.0013.36#include #include #include #include #

    14、define EmptyStack (-1)typedef float ElementType;typedef struct StackRecordint Capacity;int TopOfStack;ElementType *Array;*Stack;Stack CreateStack(int StackSize)Stack SS = (Stack)malloc(sizeof(struct StackRecord);S-Capacity = StackSize;S-TopOfStack = EmptyStack;S-Array = (ElementType*)malloc(sizeof(E

    15、lementType)*StackSize);return S;void DisposeStack(Stack S)if(S!=NULL) /* be aware of order ! */free(S-Array);free(S);/* if stack is empty, return 1 */int IsEmpty(Stack S)return S-TopOfStack = EmptyStack;/* if stack is full, return 1 */int IsFull(Stack S)return S-TopOfStack = S-Capacity;void Push(Ele

    16、mentType X, Stack S)if(IsFull(S)printf(“Stack is full ! n“);elseS-Array+S-TopOfStack = X;ElementType Pop(Stack S)if(IsEmpty(S)printf(“Stack is empty ! n“);return 0;return S-ArrayS-TopOfStack -;ElementType Top(Stack S)if(IsEmpty(S)printf(“Stack is empty ! n“);return 0;elsereturn S-ArrayS-TopOfStack;#

    17、define NUM 1#define OPRAND 0#define UNKNOWN -1struct Listint type;char opcode;float operand;int main(void)unsigned char str81; /* index */unsigned int num, p, index;float operand1,operand2;struct List pList100; /* p */Stack S;do/* get input expression */gets(str);if(strcmp(str,“0“)=0) break;/* initi

    18、alize */S = CreateStack(100);num = p = index = 0;for(index=0;indexusing namespace std;#define MAXN 110#define inf 1000000000int prim(int n,int matMAXN)int minMAXN,ret=0;int vMAXN,i,j,k;for (i=0;ini;-i)cinabc;da-1b-1=db-1a-1=c;coutusing namespace std;int main()int x1,y1,x2,y2,x,y;while(cinxy y1=y2=y;

    19、while(cinxycout#include using namespace std;int main()string pat,line;while(getline(cin,pat)getline(cin,line);for(int i=0,j;i#include using namespace std;int main()int n,t100,h,m,co=0,to=0;char cmd10,tt10;for(memset(t,-1,sizeof(t);cinn)cincmdtt;if(n0)sscanf(tt,“%d:%d“,if(cmd0=S)tn-1=h*60+m;else if(tn-1=0)+co,to+=h*60+m-tn-1,tn-1=-1;elsecout=co):0)#include #include #include using namespace std;int n,c,aa1000102,ref100010,ca=0;char ss10001010;bool cmp(int a,int b)if(c=3for(int i=0;iaai0ssiaai1,refi=i;sort(ref,ref+n,cmp);for(int i=0;iusing namespace std;int main()

    展开阅读全文
    提示  道客多多所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
    关于本文
    本文标题:浙大计算机学院考研复试上机试题.doc
    链接地址:https://www.docduoduo.com/p-2672733.html
    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    道客多多用户QQ群:832276834  微博官方号:道客多多官方   知乎号:道客多多

    Copyright© 2025 道客多多 docduoduo.com 网站版权所有世界地图

    经营许可证编号:粤ICP备2021046453号    营业执照商标

    1.png 2.png 3.png 4.png 5.png 6.png 7.png 8.png 9.png 10.png



    收起
    展开