最新小学生C++趣味编程4053Word文件下载.docx
- 文档编号:20569926
- 上传时间:2023-01-24
- 格式:DOCX
- 页数:18
- 大小:17.37KB
最新小学生C++趣味编程4053Word文件下载.docx
《最新小学生C++趣味编程4053Word文件下载.docx》由会员分享,可在线阅读,更多相关《最新小学生C++趣味编程4053Word文件下载.docx(18页珍藏版)》请在冰豆网上搜索。
sum<
2.阅读程序写结果
inti=10,n;
cin>
>
n;
while(true)
i;
if(i<
=n)break;
i-=3;
输入:
5
2.完善程序。
求风之巅小学某次信息学竞赛同学们的平均分,以-1表示输入结束。
inti=0;
floatn,pjfen,sum=0.0;
while()
i++;
cin>
if(i!
=0)
pjfen=sum/i;
”平均分:
”<
pjfen;
3.阅读程序写结果
ints,n,a;
s=0;
a=10;
while(a>
n)
s++;
a-=2;
s<
2
3.完善程序。
尼克参加了多次信息学比赛,在最近一次比赛时发现,如果这次比赛他得了98分,那么他所有比赛的平均分是92分;
如果这次得了79分,他的平均分是87分,尼克共参加了多少次比赛?
{
int;
x=2;
while(92*x-98!
=87*x-78)
;
x<
4.阅读程序写结果
intx,y,temp,ans;
x>
y;
if(x<
y)
temp=x;
x=y;
y=temp;
while(x!
=y)
x-=y;
ans=x;
ans<
287
4.完善程序。
幼儿园中班有36个小朋友,小班有30个小朋友。
按班分组,两个班各组的人数一样多,问每组最多有多少个小朋友?
intx,y,n,temp;
if(x>
n=x;
n--;
”每组的人数最多为:
n<
5.阅读程序写结果
intn,x,s=0;
x=n;
while(x>
=1)
if(n%x==0)++s;
--x;
5.完善程序。
计算2020-1+2-3+4-5+...±
n的值(n为奇数时减,偶数时加)
inti,sum,n;
”n=”;
i=1;
=n)
if()
sum-=i;
else
sum+=i;
i++;
6.阅读程序写结果
x=1;
while(x<
if(x%3==1)s+=x;
++x;
20
6.完善程序。
韩信带1500名士兵打仗,战死四五百人,幸存的士兵站3个一排,多出2人;
站5人一排,多出4人;
站7人一排,多出6人,算一算幸存的士兵至少有多少人?
inti;
i=1000;
if(i%3==2&
&
i%5==4&
i%7==6);
<
7.阅读程序写结果
inta,b,n,num=0;
a>
b>
while(a<
=b)
if(a%n==0)num++;
a++;
b-=10;
num<
11005
7.完善程序。
输入三个正整数a,b,n,输出a÷
b的值,要求计算结果精确到小数点后n(1≤n≤200)位,如输入134,输出0.3333;
输入20172710,输出74.7037037037。
inta,b,n,ans,i;
”abn=”;
a<
’/’<
b<
’=’;
ans;
’.’;
a%=b;
for(i=1;
=n;
i++)
ans=(a*10)/b;
8.阅读程序写结果
inti=1,n,ans=0;
do
ans+=i;
i+=2;
}while(i<
=n);
10
8.完善程序。
求5+10+15+20+25+...+200的和是多少?
inti=5,;
sum+=i;
=200);
”5+10+15+20+25+...+200=”<
9.阅读程序写结果
longlongn;
intsum=0,a;
a=n%2;
sum+=a;
a;
n/=2;
}while(n!
=0);
17
9.完善程序。
输入一个正整数,输出该数的位数。
如输入789,输出3;
输入445566,输出6。
longlongn,num=0;
n/=10;
}while(n>
0);
10.阅读程序写结果
intn,i,ans=0;
if(n%i==0)ans++;
10.完善程序。
输入一个浮点数,输出其小数的位数。
如输入1.6,输出1;
输90.1234567890987654321,输出19(字符输入函数getchar()的作用是从终端输入一个字符,字符输出函数putchar()的作用是向终端输出一个字符。
)
cstdio>
//调用字符输入函数getchar()
;
boolf=false;
intnum=0;
while((ch=getchar())!
=’\n’)
if(f)
if(ch>
=’0’&
ch<
=’9’)//当读入的字符非换行符时,就重复读入
//换行符用’\n’表示
else
break;
if()f=true;
if(num>
0)
”输入不正确!
}
11.阅读程序写结果
intx,ams;
x;
ans=0;
ans+=x%8;
x/=8;
}while(x!
100
11.完善程序。
格莱尔有一箱积木,用它可以拼出赛车,青蛙,毛毛虫等作品。
这箱积木共有x块积木组件,已知x与6的和是13的倍数,与6的差是12的倍数,求这箱积木至少有多少块?
intx;
x=0;
}while((x+6)%13!
=0||(x-6)%12!
12.阅读程序写结果
intn,t,ans;
n=1;
t=2;
n*=t;
ans+=n;
}while(n<
=1e+3);
return;
12.完善程序。
用另一种方算一算观众可听到多少声掌声(时间为0秒,每人同时拍了1次手,所以狐狸老师拍完10次手用了9秒,尼克用了18秒,格莱尔用了36秒)。
intans=10,time=10;
boolflag=0;
flag=0;
if(time<
=18&
time%2==0)flag=1;
=36&
time%4==0)flag=1;
if(flag)ans++;
}while(time<
=36;
13.阅读程序写结果
longlongn,ans=0,k=1;
ans+=2;
n-=k;
k+=1=*ans;
}while(k<
13.完善程序。
尼克和格莱尔玩报数游戏,尼克按1~x报数,格莱尔按1~y报数。
两个同时开始,并以同样的速度报数,当两人都报了m个数时,统计出两人同时报相同数的次数。
intn,nike,glair,num=0;
intx,y,m;
”m=”;
m;
”x,y=”;
nike=glari=0;
for(n=1;
=m;
n++)
if(nike>
x)nike=1;
glair++;
if(glair>
y)glair=1;
if(nike==glair)num++;
14.阅读程序写结果
intm,sum=0;
sum=sum*10+m%10
m/=10;
}while(m!
123
14.完善程序。
把3.14159四舍五入保留n位小数(1≤n≤5)。
如n=1时输出3.1;
n=4时输出3.1416。
doublex,y;
intn,m=1;
x=3.14159;
1||n>
5);
for(inti=1;
i<
i++)
y=(int)(x*m+0.5);
y=y/m;
y<
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 最新 小学生 C+ 趣味 编程 4053