青少年软件编程(C语言)等级考试试卷(三级)
分数:100 题数:5
一、编程题(共5题,共100分)
1.
完美立方
试题编号:202012-011
试题类型:编程题
标准答案:
试题难度:一般
试题解析:
#include <cstdio>
using namespace std;
int main()
{
int N;
scanf("%d",&N);
for(int a = 2; a <= N; ++a)
for(int b = 2; b < a; ++b)
for(int c = b; c < a; ++c)
for(int d = c; d < a; ++d)
if( a*a*a == b*b*b + c*c*c +d*d*d)
printf("Cube = %d, Triple = (%d,%d,%d)\n", a, b, c,d);
return 0;
}
2.
不定方程求解
试题编号:202012-012
试题类型:编程题
标准答案:
试题难度:一般
试题解析:
#include<iostream>
using namespace std;
int main(){
int a,b,c,x,y,s=0;
cin>>a>>b>>c;
for(x=0;x<=c/a;x++)
{
y=(c-a*x)/b;
if(a*x+b*y==c)s++;
}
cout<<s;
return 0;
}
3.
分解因数
试题编号:202012-013
试题类型:编程题
标准答案:
试题难度:一般
试题解析:
#include <stdio.h>
int count = 0;
int func(int a,int b)
{
if (a == 1) return 1;
if (b == 1) return 0;
if (a%b == 0) return func(a/b,b)+func(a,b-1);
return func(a,b-1);
}
int main()
{
int N,a;
scanf("%d",&N);
while (N--)
{
scanf("%d",&a);
printf("%d\n",func(a,a));
}
return 0;
}
4.
上台阶
试题编号:202012-014
试题类型:编程题
标准答案:
试题难度:一般
试题解析:
#include <iostream>
using namespace std;
const int N=73;
long long c[N+1]={0};
long long countN(int n)
{
c[0]=c[1]=1,c[2]=2;
for(int i=3;i<=N;i++)
{
c[i]=c[i-1]+c[i-2]+c[i-3];
}
return c[n];
}
int main()
{
int n;
countN(N);
while(cin>>n && n>0 && n<=N)
{
cout<<c[n]<<endl;
}
return 0;
}
5.
田忌赛马
试题编号:202012-015
试题类型:编程题
标准答案:
试题难度:一般
试题解析:
#include<bits/stdc++.h>
using namespace std;
int A[12];
int N,X,xy;
int x[12];
#include <iostream>
#include <algorithm>
using namespace std;
void prt(int arr[],int end){
int i;
int sum=0;
for(i=0;i<=end;i++) if(arr[i]>=A[i]+X) sum++;
if(sum>=xy)
{
for(i=0;i<=end;++i){
printf("%d ",arr[i]);
202012软件编程(C语言)真题——(3级)