2026/5/23 0:55:36
网站建设
项目流程
网站会员营销,网站开发 问题 关键技术,企业工商注册流程,做网站需要多少钱一年2025年上海交通大学计算机考研复试机试真题
2025年上海交通大学计算机考研复试上机真题
历年上海交通大学计算机考研复试上机真题
历年上海交通大学计算机考研复试机试真题
更多学校完整题目开源地址#xff1a;https://gitcode.com/u014339447/pgcode
百度一下pgcode 即…2025年上海交通大学计算机考研复试机试真题2025年上海交通大学计算机考研复试上机真题历年上海交通大学计算机考研复试上机真题历年上海交通大学计算机考研复试机试真题更多学校完整题目开源地址https://gitcode.com/u014339447/pgcode百度一下pgcode即可查看输入 “学校名称” 即可筛选该校历年机试真题包括真题、ac代码、解题思路、视频讲解。水杯倒水-上海交通大学题目描述给出三个杯子的容量A AAB BBC CC其中刚开始时C CC杯是满的A AAB BB是空的。现在在保证不会有漏水的情况下进行如下操作将一个杯子x xx的水倒到另一个杯子y yy中如果x xx空了或者y yy满了就停止满足其中一个条件才停下现问C CC中水量有多少种可能性A AAB BBC CC为非负整数输入格式输入包含多组测试数据。每组数据占一行包含三个整数A AAB BBC CC。输出格式每组数据输出一个结果占一行。输入样例0 5 5 2 2 4输出样例2 3#includebits/stdc.husingnamespacestd;structState{inta,b,c;};intmain(){ios::sync_with_stdio(false);cin.tie(nullptr);intA,B,C;while(cinABC){boolvisited[A1][B1][C1]{0};setintresult;queueStateq;q.push({0,0,C});visited[0][0][C]true;intcap[3]{A,B,C};while(!q.empty()){auto[a,b,c]q.front();q.pop();result.insert(c);intcur[3]{a,b,c};// 6 possible pours: i - jfor(inti0;i3;i){for(intj0;j3;j){if(ij)continue;intxcur[i];intycur[j];intspacecap[j]-y;if(x0||space0)continue;intpourmin(x,space);intnxt[3]{cur[0],cur[1],cur[2]};nxt[i]-pour;nxt[j]pour;if(!visited[nxt[0]][nxt[1]][nxt[2]]){visited[nxt[0]][nxt[1]][nxt[2]]true;q.push({nxt[0],nxt[1],nxt[2]});}}}}coutresult.size()\n;}return0;}String to int-上海交通大学题目描述给定一个字符串字符串前可能有很多空格字符串由数字 数字数字和各种字符组成要求找到第一个数字 数字数字。若没有找到或者其值大于i n t intint上限都返回− 1 -1−1。输入格式一行一个字符串。输出格式一个整数表示结果。输入样例2016 000687CS01输出样例2016#includeiostream#includestringusingnamespacestd;#includeclimitsintmain(){string str,judge;intc,e;intlimitINT_MAX;while(limit){judge(char)((limit%10)0)judge;limit/10;}while(getline(cin,str)){c0;while(str[c]0||str[c]9)c;ec1;while(str[e]0str[e]9)e;string ansstr.substr(c,e-c);if(ans.size()judge.size())ans-1;if(ans.size()judge.size()ansjudge)ans-1;coutansendl;}return0;}Zero-上海交通大学题目描述You are given a sequence of integer numbers. Zero-complexity transposition of the sequence is the reverse of this sequence. Your task is to write a program that prints zero-complexity transposition of the given sequence.输入格式For each case, the first line of the input file contains one integer $ n $ -length of the sequence ($ 0 n \leq 10,000 $). The second line contains $ n $ integers numbers-$ a_1, a_2, \ldots, a_n $ ($ -1,000,000,000,000,000 \leq a_i \leq 1,000,000,000,000,000 $).输出格式For each case, on the first line of the output file print the sequence in the reverse order.输入样例5 -3 4 6 -8 9输出样例9 -8 6 4 -3#includeiostream#includevectorusingnamespacestd;intmain(){intn;cinn;vectorlonglongsequence(n);for(inti0;in;i){cinsequence[i];}for(intin-1;i0;--i){coutsequence[i];if(i0){cout ;}}coutendl;return0;}走棋盘-上海交通大学题目描述给定一个N × M N \times MN×M的方格棋盘请问一个棋子从棋盘左上角出发能否在不重复经过棋盘上的方格的情况下遍历整个棋盘一次再回到起点。输入格式多组输入。输入棋盘大小N × M N \times MN×M。N , M 10 N, M 10N,M10输出格式每组数据输出一行一个结果如果能回到起点则输出Y否则输出N输入样例1 2 2 2输出样例Y YwhileTrue:try:lineinput()ifnotline:break# 使用map函数将分割后的字符串转换为整数a,bmap(int,line.split())ifa1orb1:ifa2orb2:print(N)continueelse:print(Y)continueifa%21andb%21:print(N)else:print(Y)exceptValueError:print(请输入两个有效的整数用空格分隔)exceptEOFError:break