1.#include <stdio.h>
int fun(char *s, char *t)
{ int n=0;
while(*s)
{ if(*s < 97) {
/**********found**********/
*(t+n)= *s ; n++; }
/**********found**********/
s++ ;
}
*(t+n)=0;
/**********found**********/
return n;
}
void main()
{ char s[81],t[81]; int n;
printf("\nEnter a string:\n"); gets(s);
n=fun(s,t);
printf("\nThere are %d letter which ASCII code is less than 97: %s\n",n,t);
}
2.#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
int fun(float x[], int n)
/************found************/
{int j, c=0; float xa=0.0;
for (j=0; j<n; j++)
xa += x[j]/n;
printf("ave =%f\n",xa);
for (j=0; j<n; j++)
/************found************/
if (x[j] >=xa)
c++;
return c;
}
void main ()
{float x[100] = {193.199, 195.673, 195.757, 196.051, 196.092, 196.596, 196.579, 196.763};
system("cls");
printf("%d\n", fun (x, 8));
}
3.
#include <stdio.h>
float fun(int m, int n)
{
}
void main() /* 主函数 */
{ void NONO ();
printf("P=%f\n", fun (12,8));
NONO();
}
void NONO ()
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */
FILE *fp, *wf ;
int i, m, n ;
float s;
fp = fopen("in.dat","r") ;
wf = fopen("out.dat","w") ;
for(i = 0 ; i < 10 ; i++) {
fscanf(fp, "%d,%d", &m, &n) ;
s = fun(m, n) ;
fprintf(wf, "%f\n", s) ;
}
fclose(fp) ;
fclose(wf) ;
}