题目(Description):
计算 100+102+104+106+.......n。n为偶数。
输入(Input):
大于100的偶数
输出(Output):
100+102+104+106+.......n的和
示例(Sample):
输入(Input):
106
输出(Output):
412
2.
题目(Description):
统计小于n的,既是素数又属于斐波那契数列的整数个数。
输入(Input):
正整数n
输出(Output):
既是素数又属于斐波那契数列的数的个数
示例(Sample):
输入(Input):
10
输出(Output):
3
3.
题目(Description):
输入10个整数,输出最小的5个整数之和。
输入(Input):
10个整数
输出(Output):
最小的5个整数之和
示例(Sample):
输入(Input):
10 2 3 1 9 4 0 2 -1 8
输出(Output):
4
4.
题目(Description):
编写函数digital_char,统计一个字符串(不超过20个字符)中包含的十进制数字字符出现的次数。
int digital_char(char *p)
{ }
输入(Input):
一个字符串(不多于20个字符)
输出(Output):
字符串中十进制数字字符出现的次数
提示(Hint):
程序的前缀代码已经给出,请在提交作业时注释或者去掉前缀代码。
示例(Sample):
输入(Input):
happy123
输出(Output):
3
5.
题目(Description):
编写函数mean,计算二维数组中所有元素的平均值并返回其值。
double mean(double a[M][N],int m,int n)
{ }
输入(Input):
无
输出(Output):
二维数组中所有元素的平均值
提示(Hint):
程序的前缀代码已经给出,请在提交作业时注释或者去掉前缀代码。
前缀代码: | //StudybarCommentBegin #include<stdio.h> #define M 2 #define N 3 int main() { double mean(double a[M][N],int m,int n); double a[M][N]={1,2,3,4,5,6}; printf("%lf",mean(a,2,3)); return 0; } //StudybarCommentEnd |
6.
题目(Description):
计算两个任意正整数之间的素数的个数。
输入(Input):
两个正整数
输出(Output):
两个正整数之间素数的个数
示例(Sample):
输入(Input):
1 10
输出(Output):
4
7.
题目(Description):
输入字符串,统计元音字母的个数。(元音字母:a、e、i、o、u)。
输入(Input):
一个包含数字大小写字母的字符串(该字符串的长度不超过100个字符)
输出(Output):
字符串中元音字母的个数
示例(Sample):
输入(Input):
A23ebdefa
输出(Output):
4
8.
题目(Description):
给一个5*5的二维数组a,赋1到25的自然数(按行顺序),然后输出该数组的左下半三角。
输入(Input):
无
输出(Output):
该数组的左下半三角,格式如下:
*
* *
* * *
* * * *
* * * * *
每个数占4列,且右对齐。
9.
题目(Description):
编写递归函数product,计算出一维数组中所有元素之积并返回。
int product(int a[],int n)
{ }
输入(Input):
无
输出(Output):
一维数组中所有元素之积
提示(Hint):
程序的前缀代码已经给出,请在提交作业时注释或者去掉前缀代码。
前缀代码: | //StudybarCommentBegin #include<stdio.h> int main() { int product(int a[],int n); int a[6]={1,2,3,4,5,6}; printf("%d",product(a,6)); return 0; } //StudybarCommentEnd |
10.
题目(Description):
编写函数fun,求出满足不等式1+1/2+1/3+……+1/n>5的最小n值,以及计算累加和sum。用指针作为参数,指向sum;用函数返回最小n值。
int fun(double *p)
{ }
输入(Input):
无
输出(Output):
最小n值
累加和
提示(Hint):
程序的前缀代码已经给出,请在提交作业时注释或者去掉前缀代码。
前缀代码: | //StudybarCommentBegin #include<stdio.h> int main() { int fun(double *p); double sum=0; double *p=∑ int n; n=fun(p); printf("%d\n%lf\n",n,*p); return 0; } //StudybarCommentEnd |
题目(Description):
百钱买百鸡问题:现在有100元钱,来买100只鸡(公鸡、母鸡、小鸡都有)。已知一只公鸡是5元钱,一只母鸡是3元钱,3只小鸡是1元钱,请问100元钱能买多少只公鸡、母鸡、小鸡?
输入(Input):
无
输出(Output):
公鸡数 母鸡数 小鸡数
公鸡数 母鸡数 小鸡数
......
注意:
(1)输出按照公鸡从少到多的顺序
(2)100元钱能买的公鸡、母鸡和小鸡不止一种方案。