华东师范大学计算机机试真题Word格式.docx
- 文档编号:13703049
- 上传时间:2022-10-12
- 格式:DOCX
- 页数:72
- 大小:36.07KB
华东师范大学计算机机试真题Word格式.docx
《华东师范大学计算机机试真题Word格式.docx》由会员分享,可在线阅读,更多相关《华东师范大学计算机机试真题Word格式.docx(72页珍藏版)》请在冰豆网上搜索。
2
4
#include<
stdio.h>
intmain()
{
intn;
inta,b;
intsum;
while(scanf("
%d"
&
n)!
=EOF)
while(n--)
intan=0;
scanf("
%d%d"
a,&
b);
sum=a+b;
while(sum)
{
an++;
sum/=10;
}
printf("
%d\n"
an++);
}
return0;
大写改小写
Capitalize
Writeaprogramwhichreplaceallthelower-caselettersofagiventextwiththecorrespondingcaptitalletters.
Atextincludinglower-caseletters,periods,andspace.
OutputTheconvertedtext.
welcometoeastchinanormaluniversity.
WELCOMETOEASTCHINANORMALUNIVERSITY.
string.h>
charstr[1000];
intl;
while(gets(str))
l=strlen(str);
inti;
for(i=0;
i<
l;
i++)
if(str[i]>
='
a'
&
str[i]<
z'
)
printf("
%c"
str[i]-32);
else
str[i]);
\n"
);
素数对
PrimesPair
Wearrangethenumbersbetween1andN(1<
=N<
=10000)inincreasingorderanddecreasingorderlikethis:
123456789...N
N...987654321
Twonumbersfacedeachotherformapair.YourtaskistocomputethenumberofpairsPsuchthatbothnumbersinthepairsareprime.
Thefirstlineofinputgivesthenumberofcases,C(1≤C≤100).Ctestcasesfollow.
EachtestcaseconsistsofanintegerNinoneline.
Foreachtestcase,outputP.
4
1
7
51
6
boolprime[10005];
voidinit()
intj;
prime[0]=prime[1]=false;
//不是素数
prime[2]=true;
//是素数
for(i=3;
=10005;
i+=2)
prime[i]=true;
prime[i+1]=false;
//不是素数除0和2之外的偶数都不是素数
if(prime[i]==true)//是素数
j=i+i;
while(j<
=10005)
prime[j]=false;
j+=i;
intc;
init();
//初始化
c)!
while(c--)
scanf("
n);
intsum=0;
for(i=2;
=n/2;
if(prime[i]==true&
prime[n+1-i]==true)
sum++;
sum*=2;
if(n%2==1)//n为奇数
if(prime[n/2+1]==true)
sum+=1;
sum);
求最大公约数和最小公倍数
GCDandLCM
Writeaprogramwhichcomputesthegreatestcommondivisor(GCD)andtheleastcommonmultiple(LCM)ofgivenaandb(0<
a,b≤44000).
Eachtestcasecontainstwointergeraandbseparatedbyasinglespaceinaline.
Foreachtestcase,printGCDandLCMseparatedbyasinglespaceinaline.
86
50003000
224
100015000
intgetgcd(inta,intb)
intgcd;
intt1,t2;
t1=a;
t2=b;
gcd=t1%t2;
while(gcd!
=0)
t1=t2;
t2=gcd;
returnt2;
%d%d\n"
getgcd(a,b),a*b/(getgcd(a,b)));
排序后求位置处的数
Sortit…
Thereisadatabase,partychenwantyoutosortthedatabase’sdataintheorderfromtheleastuptothegreatestelement,thendothequery:
"
Whichelementisi-thbyitsvalue?
"
-withibeinganaturalnumberinarangefrom1toN.
Itshouldbeabletoprocessquicklyquerieslikethis.
Thestandardinputoftheproblemconsistsoftwoparts.Atfirst,adatabaseiswritten,andthenthere'
sasequenceofqueries.Theformatofdatabaseisverysimple:
inthefirstlinethere'
sanumberN(1<
=N<
=100000),inthenextNlinestherearenumbersofthedatabaseoneineachlineinanarbitraryorder.Asequenceofqueriesiswrittensimplyaswell:
inthefirstlineofthesequenceanumberofqueriesK(1<
=K<
=100)iswritten,andinthenextKlinestherearequeriesoneineachline.Thequery"
iscodedbythenumberi.
TheoutputshouldconsistofKlines.Ineachlinethereshouldbeananswertothecorrespondingquery.Theanswertothequery"
i"
isanelementfromthedatabase,whichisi-thbyitsvalue(intheorderfromtheleastuptothegreatestelement).
5
121
123
5
algorithm>
usingnamespacestd;
intnum[100010];
intpos[105];
intk;
for(i=1;
=n;
num[i]);
k);
=k;
i++
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 华东师范大学 计算机 机试真题