宁波大学914c程序设计17-18年真题

合集下载

2023年浙江省宁波市全国计算机等级考试C++语言程序设计真题(含答案)

2023年浙江省宁波市全国计算机等级考试C++语言程序设计真题(含答案)

2023年浙江省宁波市全国计算机等级考试C++语言程序设计真题(含答案) 学校:________ 班级:________ 姓名:________ 考号:________一、1.选择题(10题)1.若进栈序列为a,b,C,则通过入出栈操作可能得到的a,b,C的不同排列个数为( )。

A.4B.5C.6D.72. 下列叙述中,错误的是()。

A.派生类可以使用private派生B.对基类成员的访问必须是无二义性的C.基类成员的访问能力在派生类中维持不变D.赋值兼容规则也适用于多继承的组合3.以下不是结构化程序设计方法的技术是()。

A.自顶向下,逐步求精B.自底向上,逐步求精C.从整体到局部D.结构清晰,层次分明4. 当一个函数无返回值时,函数的类型应为( )。

A.任意B.voidC.intD.char5. 有如下程序:#include <iostream>using namespace std;class point{ int x, y;public: point( int vx, int vy ) { x = vx; y = vy; } point ( ) x = 0; y= 0; } point operator+( point p1 ) { point p; int px = x+ p1.x; int py = y + p1.y; returnpoint( px, py ); point operator-( point p1 ) { point p; int px = x -p1.x; int py = y - p1.y; return point ( px, py ); } void print() { cout<<x<<" , "<<y<<end1; }};int main (){ point p1(10, 10 ), p2( 20, 20 ); p1 = p1 - p2; p1.print (); return 0;} 执行后的输出结果是A.10,10B.20,20C.10,20D.30,306.相对于数据库系统,文件系统的主要缺陷有数据关联差、数据不一致性和()。

宁波大学OJ系统240题

宁波大学OJ系统240题

1000 整数输入输出练习Description从键盘输入任意两个整数,再向屏幕输出这两个数据。

Input输入两个整数。

Output输出这两个整数。

以空格间隔。

Sample Input7 -9Sample Output7 -9HINT本题的样例代码如下:#include<stdio.h>int main(){int a,b;scanf("%d%d",&a,&b);printf("%d %d\n",a,b);return 0;1001 字符输入输出练习1 Description从键盘任意输入一个字符,再输出这个字符。

Input任意输入一个字符。

Output输出该字符。

Sample InputSample Output##include<stdio.h>int main(){char a;scanf("%c",&a);printf("%c\n",a);return 0;}1002 单组A+B Description从键盘输入任意两个整数a和b,计算并输出a+b的值。

Input从键盘输入两个整数a和b。

Output输出这两个数的和Sample Input1 2Sample Output3#include<stdio.h>int main(){int a,b,c;scanf("%d%d",&a,&b);c=a+b;printf("%d\n",c);return 0;}1003 多组A+B(1)Description分别计算多组a+b的值。

Input输入包含多组测试数据。

每行包含一组整数a,b。

当输入为0 0 时,测试结束,此时的结果不输出。

Output对于每一对整数a,b,输出它们的和,并且每行输出一个结果。

Sample Input1 510 200 0#include<stdio.h>int main(){int a,b,y;scanf("%d%d",&a,&b);while(a!=0||b!=0){y=a+b;printf("%d\n",y);scanf("%d%d",&a,&b);}return 0;}1004 多组A+B(2)Description分别计算多组a+b的值。

精编版-2016年浙江宁波大学C程序设计考研真题

精编版-2016年浙江宁波大学C程序设计考研真题

2016年浙江宁波大学C程序设计考研真题一、单项选择题:本大题共 30 小题,每小题 3 分,共 90 分。

在每小题列出的四个选项中只有一个是符合题目要求的。

错选、多选或未选均不得分。

1. 关于C语言中的函数,下列说法中错误的是___________A) 函数定义可以分为两个部分,即函数说明部分和函数体B) 主函数可以调用非主函数C) 某个非主函数可以调用其它非主函数D) 程序可以从任何函数开始执行2. C 语言中 while 和 do-while 循环的主要区别是___________A) do-while 的循环体至少无条件执行一次B) while 的循环控制条件比 do-while 的循环控制条件严格C) do-while 里面不允许使用 breakD) do-while 里面不允许使用 continue3. 在 C 语言程序中,以下说法正确的是___________A) 函数的定义可以嵌套,但函数的调用不可以嵌套B) 函数的定义不可以嵌套,但函数的调用可以嵌套C) 函数的定义和函数的调用都不可以嵌套D) 函数的定义和函数的调用都可以嵌套4. 下列字符列中,能作为某个变量的标识符是___________A) ?aB) a=2C) a.3D) a_35. 在以字节存储字符的系统中,字符‘\n ’在内存占用的字节数是___________A) 1B) 2C) 3D) 46. 下面的数字中,合法的长整型常数是___________A) 0LB) 4962710C) 0.054838743D) 2.1869e107. 下面正确表示字符常量的是___________A) "\n"B) '\t'C) "0"D) 658. 输出字符型变量 x 与整型变量 y,下列 printf 语句使用正确的是___________A) printf ("%f%s", x, y);B) printf ("%lf%c", x, y) ;C) printf ("%c%d", x, y);D) scanf ("%f%c", x, y) ;9. 为表示关系 x≥y≥z,应使用 C 语言表达式___________A) (x>=y>=z)B) (x>=y) AND (y>=z)C) (x>=y) && (y>=z)D) (x>=y) & (y>=z)10. C 语言对 if 嵌套语句的规定 else 总是与___________配对。

宁波大学考研真题914C程序设计初试试卷(B卷)硕士研究生专业课考试试题(2018年)

宁波大学考研真题914C程序设计初试试卷(B卷)硕士研究生专业课考试试题(2018年)

A)1
B)0
C)-1
D)出错
(10)在循环语句的循环体中,break 语句的作用是( ) A)继续执行 break 语句之后的循环体内其他各语句; B)提前结束本层循环,接着执行该循环体后续的语句; C)结束本次循环; D)暂停程序的运行.
(11)若用数组名作为函数调用的实参,传递给形参的是( )
A)数组的首地址
swap(int p,int q)
{
int t;
t=p;p=q;q=t;
}
Int main()
{
int a=10,b=20;
pirntf("(1) a=%d,b=%d\n",a,b);
swap(&a,&b);
printf("(2) a=%d,b=%d\n",a,b);
return 0;
}
(A) 该程序完全正确
return 0;
}
程序运行后的输出结果是( )
A) 12
B) 15
C) 6
D) 5
(8) 有以下程序
struct STU
{ char num[10]; float score[3]; };
main()
{ struct STU s[3]={{"20021",90,95,85},
{"20022",95,80,75},
题目 1:逆序数 【问题描述】给定一个整数(正整数、负整数、零),请输出它的逆序数。 【样例输入】 -12300 【样例输出】 -321
题目 2:统计单词个数 【问题描述】统计一个英文句子(长度不大于 80)中含有英文单词的个数,单词之间用空格隔开。 【样例输入】

浙江科技学院C程序设计2017--2020年考研初试真题

浙江科技学院C程序设计2017--2020年考研初试真题

第 10页,共 15页
机密 ★ 考试结束前
5. 下列程序将数组名作为函数参数,求平均成绩。请填空。 #include<stdio.h> float aver(______(13)______,int n) { int i; float av,s = a[0]; for(i = 1; i < n; i ++) s += a[i]; av = s / n; ______(14)______ ; } int main() { float sco[5],av; int i; for(i = 0; i < 5; i ++) scanf("%f",sco + i); av = aver(_____(15)______ , 5); printf("average score is %5.2f\n",av); return 0; }
【程序】 #include <stdio.h> int prime(int n); void guess(int n);
第 7页,共 15页
机密 ★ 考试结束前
void main() {
int n,n1,n2; do {
printf("Please input an even number(>=6):"); scanf("%d",&n); }while(!(n>=6&&n%2==0)); guess(n); } void guess(int n) { int n1,n2; for(n1=3;n1<=n/2;n1+=2) { n2=n-n1; if(____(4)____)

宁波大学2017年考研真题【信息科学与工程学院】911电子线路(模拟电路+数字电路)初试试卷(A卷)

宁波大学2017年考研真题【信息科学与工程学院】911电子线路(模拟电路+数字电路)初试试卷(A卷)

科目代码:911科目名称:电子线路(模拟电路+数字电路)适用专业:电路与系统通信与信息系统信号与信息处理电子与通信工程集成电路工程计算机技术一、单项选择题(本大题共5小题,每小题5分,共25分)1.电路如图1所示,二极管的导通电压0.7V D U =,则图1中二极管的工作状态及输出电压值为()。

A 、D1导通,D2截止,0.7V O U =B 、D1截止,D2导通, 5.3V O U =-C 、D1截止,D2截止,12V O U =D 、D1导通,D2导通,0.7V O U =2.对于RC 耦合单管共射放大电路,若其上、下限频率分别为H f 、L f ,则当L f f =时,下列描述正确的是()。

A 、o U 滞后i U 45︒B 、o U 滞后i U ︒135C 、o U 超前iU ︒45D 、o U 超前iU 135︒3.如下图2所示单相桥式整流、电容滤波电路,电容量足够大时,已知副边电压有效值为210V U =,测得输出电压的平均值() 4.5V O AV U =,则下列描述正确的是()。

A 、电路正常工作B 、电容C 开路C 、负载R L 开路D 、电容C 和二极管D 1同时开路图2图24.为了克服零点漂移,通用型运放的输入级大多采用()。

A 、共射电路B 、共集电路C 、差动放大电路D 、OCL 互补对称功放电路5.关于多级放大电路下列说法中错误的是()。

A 、Au 等于各级电压放大倍数之积;B 、Ri 等于输入级的输入电阻;C 、Ro 等于输出级的输出电阻;D 、级数越多,通频带越宽。

图1D1D212V+_U O 6V3kΩ科目代码:911科目名称:电子线路(模拟电路+数字电路)适用专业:电路与系统通信与信息系统信号与信息处理电子与通信工程集成电路工程计算机技术二、填空题:(每小题5分,共5题,共25分)1.用卡诺图化简法将Y ABC ABD C D ABC ACD ACD =+++++化为最简与或形式2.求逻辑函数Y ABC AC BC =++的最小项之和形式3.写出图3的输出逻辑函数式图34.在CMOS 电路中有时采用图4所示的扩展功能用法,写出Y 的逻辑式。

2018年浙江省大学生程序设计竞赛试题

2018年浙江省大学生程序设计竞赛试题

The 15th Zhejiang Provincial Collegiate Programming ContestSponsored byContest SectionApril 29, 2018Problem ListThis problem set should contain 13 (thirteen) problems on 17 (seventeen) numbered pages. Please inform a runner immediately if something is missing from your problem set.Prepared by Zhejiang University ACM/ICPC Problem Setter Team.Problem A.PeakDescriptionA sequence of n integers a1,a2,...,a n is called a peak,if and only if there exists exactly one integer k such that1<k<n,and a i<a i+1for all1≤i<k,and a i−1>a i for all k<i≤n.Given an integer sequence,please tell us if it’s a peak or not.InputThere are multiple test cases.Thefirst line of the input contains an integer T,indicating the number of test cases.For each test case:Thefirst line contains an integer n(3≤n≤105),indicating the length of the sequence.The second line contains n integers a1,a2,...,a n(1≤a i≤2×109),indicating the integer sequence. It’s guaranteed that the sum of n in all test cases won’t exceed106.OutputFor each test case output one line.If the given integer sequence is a peak,output“Yes”(without quotes), otherwise output“No”(without quotes).Examplestandard input standard output7515732 512121 41234 44321 31213212512312Yes No No No Yes No NoProblem B.King of KaraokeDescriptionIt’s Karaoke time!DreamGrid is performing the song Powder Snow in the game King of Karaoke.The song performed by DreamGrid can be considered as an integer sequence D1,D2,...,D n,and the standard version of the song can be considered as another integer sequence S1,S2,...,S n.The score is the number of integers i satisfying1≤i≤n and S i=D i.As a good tuner,DreamGrid can choose an integer K(can be positive,0,or negative)as his tune and add K to every element in D.Can you help him maximize his score by choosing a proper tune? InputThere are multiple test cases.Thefirst line of the input contains an integer T(about100),indicating the number of test cases.For each test case:Thefirst line contains one integer n(1≤n≤105),indicating the length of the sequences D and S. The second line contains n integers D1,D2,...,D n(−105≤D i≤105),indicating the song performed byDreamGrid.The third line contains n integers S1,S2,...,S n(−105≤S i≤105),indicating the standard version of the song.It’s guaranteed that at most5test cases have n>100.OutputFor each test case output one line containing one integer,indicating the maximum possible score. Examplestandard input standard output24123423465-5-4-3-2-1 543213 1NoteFor thefirst sample test case,DreamGrid can choose K=1and changes D to{2,3,4,5}.For the second sample test case,no matter which K DreamGrid chooses,he can only get at most1match.Problem C.Magic12MonthsDescriptionIt’s New Year’s Eve,and it’s also the best time of the year to play the card game Magic12Months to pray for good luck of the coming year.BaoBao has just found a deck of standard52playing cards(without Jokers)in his pocket and decides to play the game.The rules are as follows:1.Setup1.1.Remove the four‘K’s from the52cards.1.2.Shuffle the remaining48cards and divide them face down into12piles(4cards per pile)withequal probability.2.Gameplay2.1.Let p=1.2.2.Flip the card on the top of the p-th pile,check its rank r,and discard the card.2.3.If r is a number,let p=r;If r=‘A’,let p=1;If r=‘J’,let p=11;If r=‘Q’,let p=12.2.4.If the p-th pile is empty,the game ends;Otherwise go back to step2.2.When the game ends,having all the4cards of rank mflipped and discarded indicates that the m-th month in the coming year is a lucky month.BaoBao is in the middle of the game and has discarded n cards.He wants to know the probability that the i-th month of the coming year is a lucky month for all1≤i≤12when the game ends.Given these n cards,please help him calculate the answer.InputThere are multiple test cases.Thefirst line of input contains an integer T(about100)–the number of test cases.For each test case:Thefirst and only line contains an integer n(0≤n≤48)–the number offlipped cards,followed by the rank of the n cards r1,r2,...,r n(r i∈{A,2,3,4,5,6,7,8,9,10,J,Q})separated by a space in the order they areflipped.It’s guaranteed that the input describes a valid and possible situation of the game.OutputFor each test case output one line containing12numbers separated by a space,where the i-th number indicates the probability that the i-th month of the coming year is a lucky month.You should output a probability in its simplest fraction form A/B where A and B are coprime.Specifically, if the probability equals0,you should output0;If the probability equals1,you should output1. Please,DO NOT output extra spaces at the end of each line,or your answer may be considered incorrect! Examplestandard input3309Q10J Q10J10J J85765767663A24A2424472A3A4A Astandard output12/32/511/212/32/52/52/311/211/21/21/21/21/21/21/21/21/21/21/2100000000000Problem D.Sequence SwappingDescriptionBaoBao has just found a strange sequence{<s1,v1>,<s2,v2>,...,<s n,v n>}of length n in his pocket. As you can see,each element<s i,v i>in the sequence is an ordered pair,where thefirst element s i in the pair is the left parenthesis‘(’or the right parenthesis‘)’,and the second element v i in the pair is an integer.As BaoBao is bored,he decides to play with the sequence.At the beginning,BaoBao’s score is set to 0.Each time BaoBao can select an integer k,swap the k-th element and the(k+1)-th element in the sequence,and increase his score by(v k×v k+1),if and only if1≤k<n,s k=‘(’and s k+1=‘)’. BaoBao is allowed to perform the swapping any number of times(including zero times).What’s the maximum possible score BaoBao can get?InputThere are multiple test cases.Thefirst line of the input contains an integer T,indicating the number of test cases.For each test case:Thefirst line contains an integer n(1≤n≤103),indicating the length of the sequence.The second line contains a string s(|s|=n)consisting of‘(’and‘)’.The i-th character in the string indicates s i,of which the meaning is described above.The third line contains n integers v1,v2,...,v n(−103≤v i≤103).Their meanings are described above. It’s guaranteed that the sum of n of all test cases will not exceed104.OutputFor each test case output one line containing one integer,indicating the maximum possible score BaoBao can get.Examplestandard input standard output46)())()135-132 6)())()135-10032 3())1-1-13())-1-1-124 21 0 2NoteFor thefirst sample test case,the optimal strategy is to select k=2,3,5,4in order. For the second sample test case,the optimal strategy is to select k=2,5in order.Problem E.LISDescriptionDreamGrid is learning the LIS(Longest Increasing Subsequence)problem and he needs tofind the longest increasing subsequence of a given sequence a1,a2,...,a n of length n.Recall that•A subsequence b1,b2,...,b m of length m is a sequence satisfying b1=a k1,b2=a k2,...,b m=a kmand1≤k1<k2<···<k m≤n.•An increasing subsequence b1,b2,...,b m is a subsequence satisfying b1<b2<···<b m. DreamGrid defines the helper sequence f1,f2,...,f n where f i indicates the maximum length of the increasing subsequence which ends with a i.In case you don’t know how to derive the helper sequence,he provides you with the following pseudo-code which calculates the helper sequence.procedure lis_helper(a:original sequence){Let n be the length of the original sequence,f(i)be the i-th element in sequence f,and a(i)be the i-th element in sequence a}for i:=1to nf(i):=1for j:=1to(i–1)if a(j)<a(i)and f(j)+1>f(i)f(i):=f(j)+1return f{f is the helper sequence}DreamGrid has derived the helper sequence using the program,but the original sequence a1,a2,...,a n is stolen by BaoBao and is lost!All DreamGrid has in hand now is the helper sequence and two range sequences l1,l2,...,l n and r1,r2,...,r n indicating that l i≤a i≤r i for all1≤i≤n.Please help DreamGrid restore the original sequence which is compatible with the helper sequence and the two range sequences.InputThere are multiple test cases.Thefirst line of the input contains an integer T,indicating the number of test cases.For each test case:Thefirst line contains an integer n(1≤n≤105),indicating the length of the original sequence.The second line contains n integers f1,f2,...,f n(1≤f i≤n)seperated by a space,indicating the helper sequence.For the following n lines,the i-th line contains two integers l i and r i(0≤l i≤r i≤2×109),indicating the range sequences.It’s guaranteed that the original sequence exists,and the sum of n of all test cases will not exceed5×105. OutputFor each test case output one line containing n integers separated by a space,indicating the original sequence.If there are multiple valid answers,print any of them.Please,DO NOT print extra spaces at the end of each line,or your solution may be considered incorrect!Examplestandard input standard output46123243 052433123515512131 100200 200300 200400 400500 10050071231142 030303030303032111223123253 200300200500200 012003122Problem F.Now Loading!!!DescriptionDreamGrid has n integers a1,a2,...,a n.DreamGrid also has m queries,and each time he would like toknow the value of∑1≤i≤n ⌊ai⌈log p a i⌉⌋for a given number p,where⌊x⌋=max{y∈Z|y≤x},⌈x⌉=min{y∈Z|y≥x}.InputThere are multiple test cases.Thefirst line of input is an integer T indicating the number of test cases. For each test case:Thefirst line contains two integers n and m(1≤n,m≤5×105)–the number of integers and the number of queries.The second line contains n integers a1,a2,...,a n(2≤a i≤109).The third line contains m integers p1,p2,...,p m(2≤p i≤109).It is guaranteed that neither the sum of all n nor the sum of all m exceeds2×106.OutputFor each test case,output an integer(m ∑i=1i·z i)mod109,where z i is the answer for the i-th query. Examplestandard input standard output232 100100010000 1001045 2323223123123 123232423511366 45619Problem G.JUMPin’JUMP UP!!!DescriptionTired of solving mathematical equations,DreamGrid starts to solve equations related to strings:for two strings x and y with the same length consisting of lowercase English letters,calculate f(x,y,n),which is defined as the number of nonempty strings z consisting of lowercase English letters such that xz=zy and the length of z does not exceed n.DreamGrid has two strings s=s1s2...s n and t=t1t2...t m.He would like to ask several questions about the value of f(t,s[x..(x+m−1)],y),where s[x..(x+m−1)]is the substring of s starting from s x with length m and y is a given number.InputThere are multiple test cases.Thefirst line of input contains an integer T,indicating the number of test cases.For each test case:Thefirst line contains three integers n and m and q(1≤n,m,q≤105,m≤n)–the length of s,the length of t and the number of questions.The second line contains n lowercase English letters denoting the string s.The third line contains m lowercase English letters denoting the string t.Each of the next q lines contains two integers x i and y i(1≤x i≤n+1−m,1≤y i≤1018)denoting the i-th question.It is guaranteed that neither the sum of all n nor the sum of all q exceeds106.OutputFor each question,output an integer denoting the answer.Examplestandard input standard output1 423 abcd ba12 22 321 0 0Problem H.Game on a TreeDescriptionBaoBao is playing a game on a rooted tree with n vertices and(n−1)weighted edges.At the beginning of the game,a chess piece is placed on the root of the tree,which is vertex1.In each step,BaoBao can perform one of the four operations:1.Move the chess piece along an edge from its current vertex to a child vertex.This operation willcost BaoBao w units of value,where w is the weight of the edge.2.Jump the chess piece back to vertex1.This operation is free and won’t cost BaoBao any unit ofvalue.3.Set a“save point”on the current vertex of the chess piece.If a save point has been set on someother vertex before,the save point on the old vertex will be removed(so there will be at most one save point on the tree at the same time).This operation is free and won’t cost BaoBao any unit of value.4.Jump the chess piece back to the save point(the save point must be set before this operation).Thisoperation is free and won’t cost BaoBao any unit of value.The goal of the game is to visit every leaf vertex of the tree using the chess piece.Please help BaoBao calculate the minimum units of value he has to spend to achieve the goal.Recall that a leaf vertex of a tree is a vertex with no child.InputThere are multiple test cases.Thefirst line of the input contains an integer T,indicating the number of test cases.For each test case:Thefirst line contains one integer n(2≤n≤200),indicating the size of the tree.The following(n−1)lines each contains three integers u i,v i and w i(1≤u i,v i≤n,1≤w i≤109), indicating an edge connecting vertex u i and vertex v i with weight w i in the tree.It’s guaranteed that the given graph is a tree,and the sum of n over all test cases will not exceed2000. OutputFor each test case output one line containing one integer,indicating the minimum units of value BaoBao has to spend to achieve the goal.Example standardinputstandard output 381213112425426223738338121231341351261671681812100231341351261671681148107NoteThe trees of the sample test cases are shown above.For the first sample test case,BaoBao should perform the following operations:go to 2,save on 2,go to 4,go to 5,back to save (2),go to 6,back to root (1),go to 3,save on 3,go to 7,back to save (3),go to 8.For the second sample test case,BaoBao should perform the following operations:go to 2,go to 3,save on 3,go to 4,back to save (3),go to 5,back to root (1),go to 2,go to 6,save on 6,go to 7,back to save(7),go to 8.For the third sample test case,BaoBao should perform the following operations:go to 2,save on 2,go to 3,go to 4,back to save (2),go to 3,go to 5,back to save (2),go to 6,save on 6,go to 7,back to save (6),go to 8.Problem I.Magic PointsDescriptionGiven an integer n ,we say a point (x,y )on a 2D plane is a magic point,if and only if both x and y are integers,and exactly one of the following conditions is satisfied:•0≤x <n and y =0;•0≤x <n and y =n −1;•x =0and 0≤y <n ;•x =n −1and 0≤y <n .It’s easy to discover that there are 4n −4magic points in total.These magic points are numbered from 0to 4n −5in counter-clockwise order starting from (0,0).DreamGrid can create n magic lines from these magic points.Each magic line passes through exactly two magic points but cannot be parallel to the line x =0or y =0(that is to say,the coordinate axes).The intersections of the magic lines are called dream points,and for some reason,DreamGrid would like to make as many dream points as possible.Can you tell him how to create these magic lines?InputThere are multiple test cases.The first line of input contains an integer T (about 100),indicating the number of test cases.For each test case,there is only one integer n (2≤n ≤1000).OutputFor each case output 2n integers p 1,p 2,...,p 2n in one line separated by one space,indicating that in your answer,point p 2k −1and point p 2k is connected by a line for all 1≤k ≤n .If there are multiple answers,you can print any of them.Example standard inputstandard output32340213142536061938410NoteThe sample test cases are shown as follow:Problem J.CONTINUE...?DescriptionDreamGrid has n classmates numbered from1to n.Some of them are boys and the others are girls.Each classmate has some gems,and more specifically,the i-th classmate has i gems.DreamGrid would like to divide the classmates into four groups G1,G2,G3and G4such that:•Each classmate belongs to exactly one group.•Both G1and G2consist only of girls.Both G3and G4consist only of boys.•The total number of gems in G1and G3is equal to the total number of gems in G2and G4.Your task is to help DreamGrid group his classmates so that the above conditions are satisfied.Note that you are allowed to leave some groups empty.InputThere are multiple test cases.Thefirst line of input is an integer T indicating the number of test cases. For each test case:Thefirst line contains an integer n(1≤n≤105)–the number of classmates.The second line contains a string s(|s|=n)consisting of0and1.Let s i be the i-th character in the string s.If s i=1,the i-th classmate is a boy;If s i=0,the i-th classmate is a girl.It is guaranteed that the sum of all n does not exceed106.OutputFor each test case,output a string consists only of{1,2,3,4}.The i-th character in the string denotes the group which the i-th classmate belongs to.If there are multiple valid answers,you can print any of them;If there is no valid answer,output“-1”(without quotes)instead.Examplestandard input standard output5112103101400007 1101001-1-1314 1221 3413214Problem K.Mahjong SortingDescriptionDreamGrid has just found a set of Mahjong with3M suited tiles and a White Dragon tile in his pocket. Each suited tile has a suit(Character,Bamboo or Dot)and a rank(ranging from1to M),and there is exactly one tile of each rank and suit combination.Character tiles whose rank ranges from1to9Bamboo tiles whose rank ranges from1to9Dot tiles whose rank ranges from1to9White Dragon tileAs DreamGrid is bored,he decides to play with these tiles.Hefirst selects one of the3M suited tiles as the“lucky tile”,then he picks N tiles from the set of(3M+1)tiles and sorts these N tiles with the following rules:•The“lucky tile”,if contained in the N tiles,must be placed in the leftmost position.•For two tiles A and B such that neither of them is the“lucky tile”,if–A is a Character tile and B is a Bamboo tile,or–A is a Character tile and B is a Dot tile,or–A is a Bamboo tile and B is a Dot tile,or–A and B have the same suit and the rank of A is smaller than the rank of B, then A must be placed to the left of B.White Dragon tile is a special tile.If it’s contained in the N tiles,it’s considered as the original(not-lucky)version of the lucky tile during the sorting.For example,consider the following sorted tiles,where “3Character”is selected as the lucky tile.White Dragon tile,in this case,is considered to be the original not-lucky version of“3Character”and should be placed between“2Character”and“4Character”.As DreamGrid is quite forgetful,he immediately forgets what the lucky tile is after the sorting!Given N sorted tiles,please tell DreamGrid the number of possible lucky tiles.InputThere are multiple test cases.Thefirst line of the input contains an integer T,indicating the number of test cases.For each test case:Thefirst line contains two integers N and M(1≤N,M≤105,N≤3M+1),indicating the number of sorted tiles and the maximum rank of suited tiles.For the next N lines,the i-th line describes the i-th sorted tile counting from left to right.The line begins with a capital letter s i(s i∈{C,B,D,W}),indicating the suit of the i-th tile:•If s i=C,then an integer r i(1≤r i≤M)follows,indicating that it’s a Character tile with rank r i;•If s i=B,then an integer r i(1≤r i≤M)follows,indicating that it’s a Bamboo tile with rank r i;•If s i=D,then an integer r i(1≤r i≤M)follows,indicating that it’s a Dot tile with rank r i;•If s i=W,then it’s a White Drangon tile.It’s guaranteed that there exists at least one possible lucky tile,and the sum of N in all test cases doesn’t exceed106.OutputFor each test case output one line containing one integer,indicating the number of possible lucky tiles. Examplestandard input standard output439 C2 WC4 69 C2 C7 WB3 B4 D2 3100 C2 WC9 39 C1 B2 D32 4 7 25NoteFor thefirst sample,“2Character”and“3Character”are possible lucky tiles.For the second sample,“8Character”,“9Character”,“1Bamboo”and“2Bamboo”are possible lucky tiles.Problem L.Doki Doki Literature ClubDescriptionDoki Doki Literature Club!is a visual novel developed by Team Salvato.The protagonist is invited by his childhood friend,Sayori,to join their high school’s literature club.The protagonist then meets the other members of the club:Natsuki,Yuri,and the club president Monika.The protagonist starts to participate in the club’s activities such as writing and sharing poetry,and grows close to the four girls.What a lovely story!A very important feature of the game is its poetry writing mechanism.The player is given a list of various words to select from that will make up his poem.Each girl in the Literature Club has different word preferences,and will be very happy if the player’s poem is full of her favorite words.The poem writing mini-game(from wikipedia)BaoBao is a big fan of the game and likes Sayori the most,so he decides to write a poem to please Sayori.A poem of m words s1,s2,...,s m is nothing more than a sequence of m strings,and the happiness of Sayori after reading the poem is calculated by the formulaH=m∑i=1(m−i+1)·f(s i)where H is the happiness and f(s i)is Sayori’s preference to the word s i.Given a list of n words and Sayori’s preference to each word,please help BaoBao select m words from the list andfinish the poem with these m words to maximize the happiness of Sayori.Please note that each word can be used at most once!InputThere are multiple test cases.Thefirst line of input contains an integer T(about100),indicating the number of test cases.For each test case:Thefirst line contains two integers n and m(1≤m≤n≤100),indicating the number of words and the length of the poem.For the following n lines,the i-th line contains a string consisting of lowercased English letters w i (1≤|w i|≤15)and an integer f(w i)(−109≤f(w i)≤109),indicating the i-th word and Sayori’s preference to this word.It’s guaranteed that w i=w j for all i=j.OutputFor each test case output one line containing an integer H and m strings s1,s2,...,s m separated by one space,indicating the maximum possible happiness and the corresponding poem.If there are multiple poems which can achieve the maximum happiness,print the lexicographically smallest one.Please,DO NOT output extra spaces at the end of each line,or your answer may be considered incorrect!A sequence of m strings a1,a2,...,a m is lexicographically smaller than another sequence of m strings b1,b2,...,b m,if there exists a k(1≤k≤m)such that a i=b i for all1≤i<k and a k is lexicographically smaller than b k.A string s1=a1a2...a x is lexicographically smaller than another string s2=b1b2...b y,if there exists a k(1≤k≤min(x,y))such that a i=b i for all1≤i<k and a k<b k,or a i=b i for all1≤i≤min(x,y) and x<y.Examplestandard input standard output4108hello0world0 behind0far1be2spring10can15comes20 winter25if20055collegiate0 programming-5 zhejiang10 provincial5 contest-4532bcda1bcd1bbbbb132a1aa1aaa12018if winter comes can spring be far behind15zhejiang provincial collegiate programming contest 3bbbbb bcd3a aaProblem M.Lucky7DescriptionBaoBao has just found a positive integer sequence a1,a2,...,a n of length n from his left pocket and another positive integer b from his right pocket.As number7is BaoBao’s favorite number,he considers a positive integer x lucky if x is divisible by7.He now wants to select an integer a k from the sequence such that(a k+b)is lucky.Please tell him if it is possible.InputThere are multiple test cases.Thefirst line of the input is an integer T(about100),indicating the number of test cases.For each test case:Thefirst line contains two integers n and b(1≤n,b≤100),indicating the length of the sequence and the positive integer in BaoBao’s right pocket.The second line contains n positive integers a1,a2,...,a n(1≤a i≤100),indicating the sequence. OutputFor each test case output one line.If there exists an integer a k such that a k∈{a1,a2,...,a n}and(a k+b) is lucky,output“Yes”(without quotes),otherwise output“No”(without quotes).Examplestandard input standard output4374563747652 25252 426 100124No Yes Yes YesNoteFor thefirst sample test case,as4+7=11,5+7=12and6+7=13are all not divisible by7,the answer is“No”.For the second sample test case,BaoBao can select a7from the sequence to get7+7=14.As14is divisible by7,the answer is“Yes”.For the third sample test case,BaoBao can select a5from the sequence to get5+2=7.As7is divisible by7,the answer is“Yes”.For the fourth sample test case,BaoBao can select a100from the sequence to get100+26=126.As 126is divisible by7,the answer is“Yes”.。

宁波大学信号与系统2018—2020年考研真题试题

宁波大学信号与系统2018—2020年考研真题试题
2.(14 分)试计算卷积 e2tu(t) tnu(t) [ ''(t) 3 '(t) 2 (t)]etu(t) 。
3.(14 分)一个因果 LTI 系统,其输入 x(t) 、输出 y(t) 用下列微分-积分方程表示:
d y(t) 5y(t) x( ) f (t )d x(t)
dt
其中 f (t) etu(t) 3 (t) ,试求该系统单位冲激响应 h(t) 。
宁波大学 2020 年硕士研究生招生考试初试试题(B 卷)
(答案必须写在考点提供的答题纸上)
科目代码: 912 总分值: 150 科目名称:
信号与系统
1. (10 分)试计算卷积积分: y(t) 1 * 1 tt
2. (8 分)试计算卷积和: y(n) bnu(n 1) * bnu(n 2), 其中 b 1。
x(n)
u(n)
时,输出响应
y(n)
1 2
4(2)n
5 2
(3)n
u(n)
。求此系统的差分方程。
10.(12 分)已知二阶离散时间因果 LTI 系统的框图如题 10 图所示。 (1)求系统函数,并判断系统的稳定性;
(2)设抽样频率为 10kHz,输入正弦幅度为 5,频率为 1kHz,试求稳态输出幅度。
4. (18 分)一线性时不变一阶系统,在以下三种激励下,其起始状态均相同,当激励 x1(t) (t) 时 , 其 全 响 应 为 y1(t) (t) etu(t) ; 当 激 励 x2 (t) u(t) 时 , 其 全 响 应 为 y2 (t) 3etu(t) ;当激励 x3 (t) u(t) u(t 1) 时,求系统全响应。
X (z)
2z2 z2 1 z
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

B)int a[10]={};
C)int a[]=(0);
D)int a[10]={10*1};
14、定义如下变量和数组:
int k;
int a[3][3]={1,2,3,4,k=0;k<3;k++) printf(“%d”,a[k][2-k]);

A)do{i=1; s=1;
B)do{i=1; s=0;
s=s*i;
s=s*i;
i++;
i++;
}while(i<=10);
}while(i<=10);
C)i=1; s=1;
D)i=1; s=0;
do{s=s*i;
do{s=s*i;
i++;
i++;
}while(i<=10);
}while(i<=10);
#include<stdio.h>
void main( )
{ int x=1,a=0,b=0;
switch (x)
{ case 0: b++;
case 1: a++;
case 2: a++; b++;
}
printf("a=%d, b=%d\n",a,b);
}
A) a=2, b=1 B) a=1, b=1
11、下面有关 for 循环的正确描述是

A) for 循环只能用于循环次数已经确定的情况
B) for 循环是先执行循环体语句,后判断表达式
C) 在 for 循环中,不能用 break 语句跳出循环体
D)for 循环的循环体语句中,可以包含多条语句,但必须用花括号括起来
12、如下程序的输出结果是 _ 。
B) for(i=0;i<6;i++) printf("%2d",*(p+i));
C) for(i=0;i<6;i++) printf("%2d",*p++);
D) for(i=0;i<6;i++) printf("%2d",(*p)++);
3、以下不正确的叙述是

A)在 C 程序中,逗号运算符的优先级最低
B)在 C 程序中,APH 和 aph 是两个不同的变量
C)若 a 和 b 类型相同,在执行了赋值表达式 a=b 后 b 中的值将放入 a 中而 b 中的值不变
D)当从键盘输入数据时,对于整型变量只能输入整型数值,对于实型变量只能输入包含小数
点的实型数值
4、设 x、y 和 z 是 int 型变量,且 x=3,y=4,z=5,则下面表达式中值为 0 的是
B) 3.64
C) 4.14
D) 6.78
7、将 s 所指节点加到 p 所指节点之后(如下图), 其语句应为:

A) s->next = p+1; p->next = s;
B) p->next = s; s->next = p->next;
C) s->next = p->next; p->next = s->next;
A)3 5 7 B)3 6 9 C)1 5 9
D)1 4 7
15、判断字符串 a 和 b 是否相等,应当使用

A)if(a==b)
B)if(a=b)
C)if(strcpy(a,b))
D)if(strcmp(a,b)==0)

A)‘x’&&‘y’
B)x<=y
C)x||y+z&&y-z
D)!((x<y)&&!z||1)
5、对于 int x, y; 语句 if (x<0) y= -1; else if (!x) y=0; else y=1; 等价于 。
A) y=0; if (x>=0) if (x) y=1; else y= -1;
(答案必须写在考点提供的答题纸上)
科目代码:
914
适用专业:
科目名称:
计算机技术
C 程序设计
6、若有以下宏定义
#define PI
3.14
#define ADDPI (PI+1)
#define TWO_ADDPI (2*ADDPI)
则程序中表达式 x=TWO_ADDPI/2 的值为 。
A) 6.28
D) s->next = p->next; p->next = s;
8、对于以下递归函数 f, 调用 f(4),其返回值为:

int f(int n)
{ return f(n-1)+n; }
A) 10
B) 11
C) 0
D) 以上均不是
9、设有程序段,则下面描述中正确的是

int k=10;
while(k=0) k=k-1;
C) a=1, b=0
D) a=2, b=2
第 3 页 共 10 页
宁波大学 2017 年硕士研究生招生考试初试试题(A 卷)
(答案必须写在考点提供的答题纸上)
科目代码:
914
适用专业:
科目名称:
计算机技术
C 程序设计
13、以下能对一维数组 a 进行正确初始化的语句是

A)int a[10]=(0,0,0,0,0);

A) ‘0’<=c<=‘9’
B) ‘0’<=c && c<=‘9’
C) ‘0’<=c || c<= ‘9’ D)以上均不是
2、设有定义语句:int x[6]={2,4,6,8,5,7},*p=x,i; 要求依次输出 x 数组 6 个元素中的值,不
能完成此操作的语句是

A) for(i=0;i<6;i++) printf("%2d",*(p++));
宁波大学 2017 年硕士研究生招生考试初试试题(A 卷)
(答案必须写在考点提供的答题纸上)
科目代码:
914
适用专业:
科目名称:
计算机技术
C 程序设计
一、 单项选择题:本大题共 25 小题,每小题 3 分,共 75 分。
1、判断字符变量 c 的值为数字(‘0’--‘9’)则返回 1,否则返回 0,可用表达式:
A)while 循环执行 10 次
B)循环是无限循环
C)循环体语句一次也不执行
D)循环体语句执行一次
第 2 页 共 10 页
宁波大学 2017 年硕士研究生招生考试初试试题(A 卷)
(答案必须写在考点提供的答题纸上)
科目代码:
914
适用专业:
科目名称:
计算机技术
C 程序设计
10、以下能正确计算 1×2×3×…×10 的程序段是
B) if (x!=0) if (x>0) y=1; else y= -1; else y=0;
C) if (x<0) y= -1; if (x!=0) y=1; else y=0;
D) y= -1; if (x!=0) if (x>0) y=1; else y=0;
第 1 页 共 10 页
宁波大学 2017 年硕士研究生招生考试初试试题(A 卷)
相关文档
最新文档