1.函数void  fun(char  *s)用来将字符串s中所有的字符前移一个位置,串中第一个字符移到最后。
如原字符串为Mn.123xyz,调用函数后为:n.123xyzM.请直接在函数fun的{}中输入内容.
#include <stdio.h>
#include <string.h>
void fun(char *a)
{
}
void main()
{
char a[30];
strcpy(a,"Mn.123xyz");
fun(a);
printf("%s",a);
}
2.编写函数int  fun(int  *s,int  *t,int  *k)用来求出数组中值最大的元素在数组中的下标,
并存放在k所指的存储单元中,并且将最大值添加在数组的最后。形参t所指存储单元,存放数
组中数据的个数。例如,数组中数据为1,2,3,4,5,则输出最大值的下标为4,调用函数后,
数组中的内容为1,2,3,4,5,5。请直接在函数fun的{}中输入内容.
#include <stdio.h>
int fun(int *s,int *t, int *k)
{
}
void main(void)
{
int s[20],t,k,i;
t=5;
for(i=0;i<t;i++)
s[i]=i+1;
fun(s,&t,&k);
printf("k=%d\n",k);
for (i=0;i<t+1;i++)
printf("%5d",s[i]);
}
3.编写函数void  fun(char  a[][N],  char  *b),将M行N列的二维数组中的字符数据按照列的
“倒序”次序依次放入一个字符串中。例如,二维数组为
4  3  2  1  s  s  s  s
h  h  h  h 
则字符串中的内容为1sh2sh3sh4sh。请直接在函数fun的{}中输入内容
#include <stdio.h>
#define M 3
#define N 4
void fun(char a[][N], char *b)
{
}
void main()
{
char a[M][N]={'4','3','2','1','s','s','s','s','h','h','h','h'},b[M*N+1];
fun(a,b);
puts(b);
}
4.函数int  fun(int  *score,int  *below)用来将数组score中低于(不包括等于)平均分的人数
做为返回值输出,并将对应的低分依次存放在数below中。请直接在函数fun的{}中输入内容.
#include <stdio.h>
#define N 9
int fun( int *score, int *below)
}
void main()
{  int score[N],below[N];
int i,n;
for(i=0;i<N;i++)
score[i]=(i+1)*10;
n=fun(score,below);
printf("%d\n",n);
for(i=0;i<n;i++)
printf("%4d",below[i]);
}
5.函数fun的功能是:将2个两位正整数ab合为一个整数存放在c中,合并的方式是:将a的十位和
个位依次放在c的个位和十位;b的十位和个位依次放在c的百位和千位上。例如:a=45,b=12;调用函数后,
c=2154。请直接在函数fun的{}中输入内容.
#include <stdio.h>
void fun(int a,int b, int *c)
{
}
void main(void)
{
int a=45,b=12,c;
fun(a,b,&c);
printf("%d",c);
}
6.函数long  fun(int  a,int  n)的功能是:求s=aa..aa-.......-aaa-aa-a(此处a和n的值均在[1,9]范围内,
aa..aa表示n个a)。例如: a=3,n=6,则以上表达式为s=333333-33333-3333-333-33-3,fun(3,6)的返回值为296298。
请勿修改主函数和其他函数;请直接在函数fun的{}中输入内容。
#include <stdio.h>
long fun(int a,int n)
{
printf函数是一个标准库函数
}
void main(void)
{int a,n;
printf("the re
sult is %ld\n",fun(3,6));
}
7.函数int  fun(int  a,int  b,int  c,int  d)用来计算并返回4个数中的最大值。请直接在函数fun的{}中输入内容.
#include "stdio.h"
int fun(int a,int b,int c,int d)
{
}
main()
{ printf("max is %d\n",fun(1,2,3,4));
}
8.函数void  fun(long  s,long  *t)的功能是:从低位开始取出正数s中奇数位上的数,依次构成一个新的数,
存放在t中。例如,s为7654321时,t中的数为:7531。请勿修改主函数和其他函数;请直接在函数fun的{}中输入内容。
#include <stdio.h>
void fun(long s,long *t)
{
}
void main(void)
{long s=7654321,t;
fun(s,&t);
printf("t =%ld\n",t);
}
9.函数void  fun(char  *s)的功能是:先保持原s串(长度不超过20)的内容不变,再将原s串的内容逆序连接
在后面组成一个新的s串。 例如,原s串为"abcde",则调用fun函数后,s串中的内容变为"abcdeedcba"。请勿
修改主函数和其他函数;请直接在函数fun的{}中输入内容。
#include <stdio.h>
#include <string.h>
#define N 50
void fun(char *s)
{
}
void main(void)
{char s[N];
strcpy(s,"abcde");
fun(s);
puts(s);
}
10.编写函数int  fun(int  *s,int  *t,int  *k)用来求出数组中值最大的元素在数组中的下标,并存放在
k所指的存储单元中,并且将最大值添加在数组的最后。形参t所指存储单元,存放数组中数据的个数。例如,
数组中数据为1,2,3,4,5,则输出最大值的下标为4,调用函数后,数组中的内容为1,2,3,4,5,5。请直接
在函数fun的{}中输入内容.
#include <stdio.h>
int fun(int *s,int *t, int *k)
{
}
void main(void)
{
int s[20],t,k,i;
t=5;
for(i=0;i<t;i++)
s[i]=i+1;
fun(s,&t,&k);
printf("k=%d\n",k);
for (i=0;i<t+1;i++)
printf("%5d",s[i]);
}
11.函数int  fun(char  *str)用来统计字符串str中除英文字母外其他字符的个数并返回。请勿修改主函数,
请直接在函数fun的{}中输入内容。
#include "stdio.h"
#include "string.h"
int fun(char *str)
{
}
main()
{char str1[100];
strcpy(str1,"a1b2c3d?e#");
printf("character =%d\n",fun(str1));
}
12.函数void  fun(int  x,int  pp[],int  *n)用来求出能整除x,且不是偶数的各正整数,并放在pp所指的数组中,
这些数的个数通过n返回(不考虑x>150的情况)。例如,x为30,则有4个数符合条件:1,3,5,15。请直接在函数
fun的{}中输入内容.
#include <stdio.h>
void fun(int x, int pp[], int *n)
{
}
void main()
{
int pp[20];
int i,n;
fun(30,pp,&n);
for(i=0;i<n;i++)
printf("%4d",pp[i]);
}
13.函数int  fun(int  n)用来计算正整数n的所有因子(1和n本身除外)之和作为函数值返回。例如:n=120时,
函数值为239。请直接在函数fun的{}中输入内容.
#include <stdio.h>
int fun(in
t n)
{
}
void main(void)
{
printf("%5d",fun(120));
}
14.编写函数void  fun(char  a[],int  k,int  n)功能是:删除字符串a中指定下标k开始的n个字符。例如字符串
内容是hellollo  world!若k值为5,n值为3,则调用函数后的结果为hello  world!。请直接在函数fun的{}中输入内容.
#include <stdio.h>
#include <string.h>
void fun(char a[], int k,int n)
{
}
void main(void)
{
char a[100]="hellollo world!";
fun(a,5,3);
if(strcmp(a,"hello world!")==0) puts(a);
}
15.函数void  fun(int  a[M][N],  int  b[M])用来求出一个M*N的二维数组每行元素的和,并且依次放入
一个一维数组中。例如,有二维数组:
6 10  2 10 16
17 15 15  8  6
4 18 11 19 12
0 12  1  3  7
则输出44 61 64 23
请直接在函数fun的{}中输入内容.
#include <stdio.h>
#define M 4
#define N 5
void fun(int a[M][N], int b[M])
{
}
void main()
{
int a[M][N]={6,10,2,10,16,17,15,15,8,6,4,18,11,19,12,0,12,1,3,7}, b[M];
int i;
fun(a,b);   
for(i=0;i<M;i++)
printf("%5d",b[i]);
}
16.编写函数void  fun(int  *a,  int  *n,  int  m),用来求出[1,m]中能被7或者11整除的所有整数,并放在
数组a中,通过n返回这些数的个数。 例如,若m值为50,则a中数据应该
为:7  11  14  21  22  28  33  35  42  44  49。请直接在函数fun的{}中输入内容.
#include <stdio.h>
void fun(int *a, int *n, int m)
{
}
void main()
{
int a[50];
int m,n,i;
m=50;
fun(a,&n, m);
printf("n=%d\n",n);
for(i=0;i<n;i++)
printf("%5d",a[i]);
}
17.函数void  fun(int  a,int  b,  int  *c)的功能是:将2个两位正整数ab合为一个整数存放在c中,
合并的方式是:将a的十位和个位依次放在c的个位和百位;b的十位和个位依次放在c的千位和十位上。
例如:a=45,b=12;调用函数后,c=1524。请直接在函数fun的{}中输入内容.
#include <stdio.h>
void fun(int a,int b, int *c)
{
}
void main()
{
int a,b,c;
fun(45,12,&c);
printf("%d",c);
}
18.假设变量S,I,X,N,E各代表一个十进制数字。有两个自然数SIX和NINE,它们满足的条件是
SIX+SIX+SIX=NINE+NINE。
请编写函数int  fun(int  six[],int  nine[]),求出所有满足条件的自然数SIX和NINE,
分别存入数组six  nine,并返回解个数。
#include <stdio.h>
int fun(int six[],int nine[])
{
}
void main()
{
int cnt=0;
int six[50],nine[50];
cnt=fun(six,nine);
printf("满足条件的个数=%d\n",cnt);
}
19.、 函数int  fun(char  *str)用来统计字符串str中包含的英文字母的个数并返回。
请勿修改主函数,请直接在函数fun的{}中输入内容。
#include "stdio.h"
#include "string.h"
int fun(char *str)
{
}
main()
{char str1[100];
strcpy(str1,"a1b2c3d?e#");
printf("character =%d\n",fun(str1));
}
20.函数fun()用来将s所值字符串
中下标为奇数、同时ascii码也为奇数的字符删除,串中剩余的字符形
成一个新串放在t所指数组中。若s所指串为"ABCDEFG12345",t中最后内容为"ABCDEFG24"。请直接在函
数fun的{}中输入内容.
#include <stdio.h>
#include <string.h>
void fun(char *s,char *t)
{
}
void main(void)
{
char s[40];
char t[20];
strcpy(s,"ABCDEFG12345");
fun(s,t);
puts(t);
}
21.编写一个函数fun,它的功能是:实现2个字符串的连接(不得使用库函数strcat)
例如:分别输入下面2个字符串:
p1=FirstString--
p2=SecondString
程序输出p1:FirstString--SecondString
请直接在函数fun的{}中输入内容.
#include <stdio.h>
#include <conio.h>
void fun(char p1[],char p2[])
{
}
main()
{
char s1[80]="FirstString--";
char s2[40]="SecondString";
fun(s1,s2);
printf("After invoking:%s\n",s1);
}
22.所谓回文数是指其各位数字左右对称的整数,例如121,676,94249等。满足上述条件
的数如m=11,m2=121,m3=1331皆为回文数。
请编制函数int  isHWFun(long  m)实现此功能:如果是回文数,则函数返回1,反之则返回0。
#include <stdio.h>
int isHWFun(long n)
{
}
main()
{
long m;
for(m=11;m<1000;m++)
{
if(isHWFun(m))
{
printf("m=%4ld\n",m);
}
}
23.请编写函数int  fun(int  a[][N]),函数功能是实现N*N的二维数组中第一列元素中的值
与最后一列中的值对调;第二列元素中的值与倒数第二列元素中的值对调、依次类推。如二维数组中值为:
0  11  12  7  9
1  9  7  4  5
20  13  18  3  1
14  5  6  8  2
15  9  17  4  1
则调用函数后,数组中的值为:
9 7 12 11  0
5 4  7  9  1
1 3 18 13 20
2 8  6  5 14
1 4 17  9 15
请勿修改主函数和其他函数;请直接在函数fun的{}中输入内容。
#include <stdio.h>
#define N 5
void fun(int a[][N])
{
}
void main(void)
{ int a[N][N]={0,11,12,7,9,1,9,7,4,5,20,13,18,3,1,14,5,6,8,2,15,9,17,4,1};
int i,j;
fun(a);
for(i=0;i<N;i++)
{for(j=0;j<N;j++)
printf("%4d",a[i][j]);
printf("\n");
}
}
24.函数void  fun(long  s,long  *t)的功能是:从低位开始取出正数s中偶数位上的数,
依次构成一个新的数,存放在t中。例如,s为7654321时,t中的数为:642。请勿修改主函数
和其他函数;请直接在函数fun的{}中输入内容。
#include <stdio.h>
void fun(long s,long *t)
{
}
void main(void)
{long s=7654321,t;
fun(s,&t);
printf("t =%ld\n",t);
}
25.函数void  fun(char  *s)用来把字符串中所有的字母改成该字母的下一个字母,最后一
个字母Z改成A;大写字母仍为大写,小写字母仍为小写,其他字符不变。例如:原字符串
为Mn.123xyZ,调用该函数后,串中内容为No.123yzA。请直接在函数fun的{}中输入内容.
#inclu
de <stdio.h>
#include <string.h>
void fun(char *s)
{
}
void main()
{
char s[50]="Mn.123xyZ";
fun(s);
printf("%s",s);
}
26.函数void  fun(char  *tt,int  pp[])用来统计字符串tt中'a'到'g'(小写)各出现了多少次,
并依次放在pp所指数组中。当输入字符串abcdefgabcdeabc后,pp中的内容应该是3332211。
请直接在函数fun的{}中输入内容.
#include <stdio.h>
#include <string.h>
void fun(char *tt, int pp[])
{
}
void main()
{
char tt[30];
int pp[7];
int i;
strcpy(tt,"abcdefgabcdeabc");
fun(tt,pp);
for(i=0;i<7;i++)  printf("%4d",pp[i]); 
}
27.函数void  fun(int  a,int  b,  int  *c)的功能是:将2个两位正整数ab合为一个整数存放在c中,
合并的方式是:将a的十位和个位依次放在c的个位和百位;b的十位和个位依次放在c的十位和千位上。
例如:a=45,b=12;调用函数后,c=2514。请直接在函数fun的{}中输入内容.
#include <stdio.h>
void fun(int a,int b, int *c)
{
}
void main()
{
int a,b,c;
fun(45,12,&c);
printf("%d",c);
}
28.假设变量S,I,X,N,E各代表一个十进制数字。有两个自然数SIX和NINE,它们满足的条件是
SIX+SIX+SIX=NINE+NINE。 请编写函数int  fun(int  six[],int  nine[]),求出所有满足条件的
自然数SIX和NINE,分别存入数组six  nine,并返回解个数。
#include <stdio.h>
int fun(int six[],int nine[])
{
}
void main()
{
int cnt=0;
int six[50],nine[50];
cnt=fun(six,nine);
printf("满足条件的个数=%d\n",cnt);
}
29.函数float  fun(int  a,int  b,int  c)用来判断三个整数abc是否能构成三角形;若不能,返回-1.0;
若能,返回三角形的面积;请勿修改主函数,请直接在函数fun的{}中输入内容。
#include "stdio.h"
#include "math.h"
float fun(int a,int b,int c)
{
}
main()
{
printf("area is %f\n",fun(3,4,5));
}
30函数int  fun(int  n)用来计算正整数n的所有因子(1和n本身除外)之和作为函数值返回。
例如:n=120时,函数值为239。请直接在函数fun的{}中输入内容.
#include <stdio.h>
int fun(int n)
{
}
void main(void)
{
printf("%5d",fun(120));
}
31.编写函数fun,它的功能是:求Fibonacci数列中大于t的最小的一个数,结果由函数返回。
其中Fibonacci数列F(n)的定义为:
F(0)=0,F(1)=1
F(n)=F(n-1)+F(n-2)
例如:当t=1000时,函数值为:1597。
请勿改动主函数main()。
#include <stdio.h>
int fun(int t)
{
}
main()
{
int n;
n=1000;
printf("n=%d,f=%d\n",n,fun(n));
}
32.函数long  fun(int  a,int  n)的功能是:求s=aa..aa-.......-aaa-aa-a
(此处a和n的值均在[1,9]范围内,aa..aa表示n个a)。例如:
a=3,n=6,则以上表达式为s=333333-33333-3333-333-33-3,fun(3,6)的返回值为296298。
请勿修改主函数和其他函数;请