好文档 - 专业文书写作范文服务资料分享网站

c语言20题上机题目 

天下 分享 时间: 加入收藏 我要投稿 点赞

跟着就是n个整数。n=0表示输入的结束,不做处理。

Output

对于每组输入数据,输出交换后的数列,每组输出占一行。

Sample Input

4 2 1 3 4 5 5 4 3 2 1 0

Sample Output

1 2 3 4 1 4 3 2 5

20.首字母变大写

Problem Description

输入一个英文句子,将每个单词的第一个字母改成大写字母。

Input

输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行。

Output

请输出按照要求改写后的英文句子。

Sample Input

i like acm i want to get an accepted

Sample Output

I Like Acm I Want To Get An Accepted

答案:

1.#include?? int main()??

{double r,V,pi;??

while(scanf(\ {pi=3.1415927;?? V=(4.0/3)*pi*r*r*r;?? printf(\ }??

return 0;?? }

2.#include??

??int main()?? {int a,s;??

while(scanf(\ {if(a>100||a<0)??

printf(\ else{ s=a/10;?? switch(s)?? { case 0:?? case 1:?? case 2:?? case 3:?? case 4:??

case 5:printf(\ case 6:printf(\ case 7:printf(\ case 8:printf(\ case 9:??

case 10:printf(\ ???? }?? }?? }??

??return 0; ??}

3.#include?? void main()??

{int months[12]={0,31,28,31,30,31,30,31,31,30,31,30};?? int year, month,day;?? int flag,i;?? int sum;??

while(scanf(\ {sum=0;??

for( i=0;i

if((year%4==0)||(year0!=0&&year@0==0))?? {flag=1;?? }?? else??

{flag=0;?? }??

sum=sum+day+flag;?? printf(\ } ??}??

4.#include?? main()??

{??

int n,a,p;??

while(scanf(\ {??

p=1;??

while(n--)?? {??

scanf(\ if(a%2==1) p=p*a;?? }??

printf(\ }?? }

5.#include?? int main()?? {??

int a,b,i,p,l,t;??

while(scanf(\ {?? if(a>b)?? {?? t=a;?? a=b;?? b=t;?? }??

l=p=0;??

for(i=a;i<=b;i++)\\\\这里第二个i被我写成了a T0T?? {??

if(i%2==0)?? { p=p+i*i;?? }?? else?? {?? l=l+i*i*i;?? }?? }??

printf(\ }?? return 0;??}

6.#include ??main()?? {??

int n,x,i,a,b,c;??

while(scanf (\

{??

a=0;b=0;c=0;?? for (i=0;i

scanf (\ if (x<0)?? a++;?? else ?? if (x=0)?? b++;?? else ?? if (x>0)?? c++;?? }??

printf (\ }?? ?? }

7.#include

??#include ??int main()?? {int n,m,i,j; ??float s[100];?? scanf(\ for(i=0;i

s[i]=0;??

scanf(\}??for(i=0;i

for(j=1;j<=n;j++)??

s[i]=s[i]+(pow((-1),(j+1))/j);?? }??

for(i=0;i

8.#include?? #include ??#include?? int a[3001];??main()?? {??

int n,x,y,i,j,f;??

for(i=2;i<=3000;i++)?? a[i]=1;??

for(i=2;i<=3000;i++)?? {??

if(1==a[i])?? {??

for(j=i+1;j<=3000;j++)?? if(0==j%i) a[j]=0; ?? }?? } ??

while(scanf(\ {?? f=0;??

if(x>y){n=x;x=y;y=n;}?? for(n=x;n<=y;n++)?? {??

if(!a[n*n+n+41])?? {?? f=1;?? break;?? }?? }??

if(!f) printf(\ else printf(\ }?? }

9.#include ?? int main(void)?? {??

int n,sum,i;??

while(scanf(\ {??

sum=1;??

for(i=1;i

10.#include?? #include?? int main()?? {?? int n,i;??

float a[100],sum,av,max,min;?? while(scanf(\

639lz8k7b605ej21u0rq9kfa25180i00k5c
领取福利

微信扫码领取福利

微信扫码分享