⣨һ
дfunĹǼмֵͣɺֵء
S1x^/^/^/
磬n10x0.3ʱֵΪ1.349859
ע⣺ĶmainеκݣںfunĻд䡣
#include<conio.h>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
double fun(double x, int n)
{
  

}
void main()
{ 
  FILE *wf;
  system("CLS");
  printf("%f ",fun(0.3,10));
/******************************/
  wf=fopen("out.dat","w");
  fprintf(wf,"%f",fun(0.3,10));
  fclose(wf);
/*****************************/
}

⣨
дfun书ǣ11000ܱ֮711ͬʱ711aָУͨnЩĸ
ע⣺ĶmainеκݣںfunĻд䡣
#include <stdio.h>
void  fun (int *a, int *n)
{


}
main( )
{  int aa[1000], n, k ;
   void NONO (  );
   fun ( aa, &n ) ;
   for ( k = 0 ; k < n ; k++ )
      if((k + 1) % 10 == 0) printf("\n") ;
      else printf("%5d", aa[k]) ;
   NONO( );
}
void NONO ( )
{/* ڴļݣfunݣرļ*/
  int aa[1000], n, k ;
  FILE *fp ;
  fp = fopen("out.dat","w") ;
  fun ( aa, &n ) ;
  for ( k = 0 ; k < n ; k++ )
    if((k + 1) % 10 == 0) fprintf(fp, "\n") ;
    else fprintf(fp, "%5d", aa[k]) ;
  fclose(fp) ;
}

⣨
дfun,úĹǣsַָASCIIֵΪżַɾ,ʣַγһ´tָС
,sַָеΪ"ABCDEFG12345",ַBASCIIֵΪż,ַ2ASCIIֵΪż,Ӧɾ,ơtָеӦ"ACEG135"
ע⣺ĶmainеκݣںfunĻд䡣
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
void fun(char  *s, char t[])
{
  

}
void main()
{
  FILE *wf;
  char s[100],t[100];
  system("CLS");
  printf("\nPlease enter string S: ");  
  scanf("%s",s);
  fun(s,t);
  printf("\nThe result is :%s\n",t);
/******************************/
  wf=fopen("out.dat","w");
  fun("ABCDEFG12345",t);
  fprintf(wf,"%s",t);
  fclose(wf);
/*****************************/
}

⣨ģ
дvoid  fun (int x, int pp[], int *n)ĹǣxҲżĸС˳ppָУЩĸͨβnء
磬xеֵΪ304Ҫ13515
ע⣺ĶmainеκݣںfunĻд䡣
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
void fun (int x, int pp[], int *n)
{
  

}
void main ()
{ 
  FILE *wf;
  int  x,aa[1000], n, i ;
  system("CLS");
  printf("\nPlease enter an integer number : \n ") ;
  scanf ("%d", &x) ;
  fun (x, aa, &n) ;
  for (i=0 ; i<n ; i++)
      printf ("%d ", aa [i]);
  printf ("\n ") ;
/******************************/
  wf=fopen("out.dat","w");
  fun (30, aa, &n) ;
  for (i=0 ; i<n ; i++)
      fprintf (wf,"%d ", aa [i]);
  fclose(wf);
/*****************************/
}

⣨壩
ຯfun书ǽһַתֵͬĳɵstrlenַĳȡ磺ڼַ2345210س2345210
ע⣺ĶmainеκݣںfunָĲλд䡣
#include   <stdio.h>
#include   <string.h>
void NONO();
long  fun( char  *s )
{


}
main()
{  char  s[10];  long  r;
   printf("һȲ9ַַ :  ");  gets(s);
   r = fun( s );
   printf(" r = %ld\n" , r );
   NONO();
}
void NONO()
{/* ڴļݣúݣرļ */
  FILE *fp, *wf ;
  int i;  long r;
  char s[10], *p;
  fp = fopen("in.dat","r") ;
  wf = fopen("out.dat","w") ;
  for(i = 0 ; i < 10 ; i++) {
    fgets(s, 10, fp);
    p = strchr(s, '\n');
    if(p) *p = 0;
    r = fun(s);
    fprintf(wf, "%ld\n", r);
  }
  fclose(fp) ;
  fclose(wf) ;
}

⣨
ٶַֻĸ*šдfun书ǣβ*֮⣬ַе*ȫɾβpַָһĸڱдʱʹCṩַ
磬ַеΪ****A*BC*DEF*G*******ɾַеӦABCDEFG*******
ע⣺ĶmainеκݣںfunĻд䡣
#include <stdio.h>
void  fun( char *a, char *p )
{


}
main()
{  char  s[81],*t;
   void NONO (  );
   printf("Enter a string:\n");gets(s);
   t=s;
   while(*t)t++;
   t--;
   while(*t=='*')t--;
   fun( s , t );
   printf("The string after deleted:\n");puts(s);
   NONO();
}
void NONO()
{/* ڴļݣúݣرļ */
  FILE *in, *out ;
  int i ; char s[81],*t ;
  in = fopen("in.dat","r") ;
  out = fopen("out.dat","w") ;
  for(i = 0 ; i < 10 ; i++) {
    fscanf(in, "%s", s) ;
    t=s;
    while(*t)t++;
    t--;
    while(*t=='*')t--;
    fun(s,t) ;
    fprintf(out, "%s\n", s) ;    
  }
  fclose(in) ;
  fclose(out) ;
}

⣨ߣ
дvoid fun(char *ttint pp[])ͳttַָ'a''z'26СдĸԳֵĴηppָС
磬ַabcdefgabcdeabc󣬳Ӧǣ
3 3 3 2 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ע⣺ĶmainеκݣںfunĻд䡣
#include <stdio.h>
#include <string.h>
void fun(char *tt, int pp[])
{


}
main( )
{  char aa[1000] ;
   int  bb[26], k ;
   void NONO (  );
   printf( "\nPlease enter  a char string:" ) ; scanf("%s", aa) ;
   fun(aa, bb ) ;
   for ( k = 0 ; k < 26 ; k++ ) printf ("%d ", bb[k]) ;
   printf( "\n" ) ;
   NONO ( ) ;
}
void NONO ( )
{/* ڴļݣfunݣرļ*/
  char aa[1000] ;
  int bb[26], k, i ;
  FILE *rf, *wf ;
  rf = fopen("in.dat","r") ;
  wf = fopen("out.dat","w") ;
  for(i = 0 ; i < 10 ; i++) {
    fscanf(rf, "%s", aa) ;
    fun(aa, bb) ;
    for ( k = 0 ; k < 26 ; k++ ) fprintf (wf, "%d ", bb[k]) ;
    fprintf(wf, "\n" ) ;
  }
  fclose(rf) ;
  fclose(wf) ;
}

⣨ˣ
гNNĶά飬Զֵдfun(int a[][N])úĹǣ°Ԫеֵȫó0aеֵΪ
1  9  7
2  3  8
4  5  6
򷵻aеֵӦΪ
0  9  7
0  0  8
0  0  0
ע⣺ĶmainеκݣںfunĻд䡣
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#define N 5
void fun (int a[][N])
{
 

}
void main()
{ 
  FILE *wf;
  int a[N][N],i,j;
  int b[N][N]={1,9,7,2,4,2,3,8,1,2,4,5,6,7,5,4,0,6,8,0,2,7,1,6,4};
  system("CLS");
  printf("*****The array*****\n");
  for(i=0;i<N;i++)              /*һ5*5*/
  { for(j=0;j<N;j++)
        {a[i][j]=rand()%10; 
         printf("%4d", a[i][j]);
        }
     printf("\n");
  }
  fun(a);
  printf("THE RESULT\n");
  for(i=0;i<N;i++)
  { for(j=0;j<N;j++) 
        printf("%4d",a[i][j]);
     printf("\n");
  }
/******************************/
  wf=fopen("out.dat","w");
  fun(b);
  for(i=0;i<N;i++)
  { for(j=0;j<N;j++) 
       fprintf(wf,"%4d",b[i][j]);
    fprintf(wf,"\n");
  }
  fclose(wf);
/*****************************/
}

⣨ţ
дfunúĹǣɾһάͬʹֻ֮ʣһеѰС˳Уɾݵĸ
磬һάеǣ
2 2 2 3 4 4 5 6 6 6 6 7 7 8 9 9 10 10 10
ɾеӦǣ
2 3 4 5 6 7 8 9 10
ע⣺ĶmainеκݣںfunĻд䡣
#include <stdio.h>
#define N 80
int fun(int a[], int n)
{
  

}
void main()
{ 
  FILE *wf;
  int a[N]={ 2,2,2,3,4,4,5,6,6,6,6,7,7,8,9,9,10,10,10,10}, i, n=20;
  printf("The original data :\n");
  for(i=0; i<n; i++)  
     printf("%3d",a[i]);
  n=fun(a,n);
  printf("\nThe data after deleted :\n");
  for(i=0; i<n; i++)  
     printf("%3d",a[i]);  
  printf("\n");
/******************************/
  wf=fopen("out.dat","w");
  for(i=0; i<n; i++)  
     fprintf(wf,"%3d",a[i]);
  fclose(wf);
/*****************************/
}

⣨ʮ
funĹǣsַָг±ΪżͬʱASCIIֵҲΪżַ⣬ȫɾַʣַγɵ´tָС
磬sַָеΪ"ABCDEFG123456"ַAASCIIֵΪӦɾַBASCIIֵΪżе±ΪҲӦɾַ2ASCIIֵΪżе±ҲΪż˲ӦɾơtָеӦ"246"
ע⣺ĶmainеκݣںfunĻд䡣
#include <stdio.h>
#include <string.h>
void fun(char *s, char t[])
{


}
main()
{
  char  s[100], t[100];
  void NONO (  );
  printf("\nPlease enter string S:"); scanf("%s", s);
  fun(s, t);
  printf("\nThe result is: %s\n", t);
  NONO();
}
void NONO ( )
{/* ڴļݣúݣرļ */
  char s[100], t[100] ;
  FILE *rf, *wf ;
  int i ;
  rf = fopen("in.dat","r") ;
  wf = fopen("out.dat","w") ;
  for(i = 0 ; i < 10 ; i++) {
    fscanf(rf, "%s", s) ;
    fun(s, t) ;
    fprintf(wf, "%s\n", t) ;
  }
  fclose(rf) ;
  fclose(wf) ;
}

⣨ʮһ
дfun书ǣҳ2MͶάԪصֵֵصú
ע⣺ĶmainеκݣںfunĻд䡣
#include <stdio.h>
#define M 4
int fun (int a[][M])
{


}
main( )
{  int arr[2][M]={5,8,3,45,76,-4,12,82} ;void NONO ();
   printf("max =%d\n", fun(arr)) ;
   NONO( ) ;
}
void NONO ()
{/* ڴļݣúݣرļ */
  FILE *wf ;
  int arr[][M]={5,8,3,90,76,-4,12,82} ;

  wf = fopen("out.dat","w") ;
  fprintf(wf, "max=%d\n", fun(arr)) ;
  fclose(wf) ;
}

⣨ʮ
дһfunĹǣssַָ±ΪλõĸתΪд(λϲĸת)
磬"abc4Efg"Ӧ"aBc4EFg"
ע⣺ĶmainеκݣںfunĻд䡣
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void fun(char *ss)
{
 
 
}
void main()
{
  FILE *wf;
  char tt[81],s[81]="abc4Efg";
  system("CLS");
  printf("\nPlease enter an string within 80 characters:\n");
  gets(tt);
  printf("\nAfter changing, the string\n  %s",tt);
  fun(tt);
  printf("\nbecomes\n %s\n",tt);
/******************************/
  wf=fopen("out.dat","w");
  fun(s);
  fprintf (wf,"%s",s);
  fclose(wf);
/*****************************/
}

⣨ʮ
дfunúĹǣMNеĶάеַݣе˳ηŵһַС
磬άеΪ
W W W W
S S S S
H H H H
ַеӦǣWSHWSHWSHWSH
ע⣺ĶmainеκݣںfunĻд䡣
#include<stdio.h>
#define  M  3
#define  N  4
void fun(char (*s)[N],char *b)
{
 
 
}
void main()
{ 
  FILE *wf;
  char a[100],w[M][N]={{ 'W', 'W', 'W', 'W'},{'S', 'S', 'S', 'S'},{'H', 'H', 'H', 'H'}};
  int i,j;
  printf("The matrix:\n");
  for(i=0;i<M;i++)
  { for(j=0;j<N;j++) 
       printf("%3c",w[i][j]);
    printf("\n");
  }
  fun(w,a);
  printf("The A string:\n");
  puts(a);
  printf("\n ");
/******************************/
  wf=fopen("out.dat","w");
  fprintf(wf,"%s",a);
  fclose(wf);
/*****************************/
}

⣨ʮģ
֪ѧļ¼ѧźѧϰɼɣNѧѴaṹСдfunúĹǣҳɼߵѧ¼ͨβη(涨ֻһ߷)Ѹײɸú
ע⣺ĶmainеκݣںfunĻд䡣
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#define N 10
typedef struct ss    /*ṹ*/
{ char num[10]; 
  int s;
} STU;
fun(STU a[], STU *s)
{

  
}
void main()
{ 
  FILE *wf;
  STU a[N]={{ "A01",81},{ "A02",89},{ "A03",66},{ "A04",87},{ "A05",77},
  { "A06",90},{ "A07",79},{ "A08",61},{ "A09",80},{ "A10",71}},m;
  int i;
  system("CLS");
  printf("*****The original data*****");
  for(i=0;i<N;i++) 
     printf("No=%s Mark=%d\n", a[i].num,a[i].s);
  fun(a,&m);
  printf("*****THE RESULT*****\n");
  printf("The top :%s, %d\n",m.num,m.s);
/******************************/
  wf=fopen("out.dat","w");
  fprintf(wf,"%s,%d",m.num,m.s);
  fclose(wf);
/*****************************/
}

⣨ʮ壩
дfun书ǣжβnеǼλݵλ4λֵͨء磺Ϊ 123Ϊ3λ
ע⣺Ķmainеκ
ݣںfunĻд䡣
#include  <stdio.h>
void NONO();
int  fun(int  n)
{


}
main()
{  int  n, place ;
   do{
      printf("һ4λڵ:    ");
      scanf("%d", &n);
     }  while (n<0 || n>9999);
   place = fun(n);
   printf( "%dλ\n", place );
   NONO();
}
void NONO()
{/* ڴļݣúݣرļ */
  FILE *fp, *wf ;
  int i, n, place ;
  fp = fopen("in.dat","r") ;
  wf = fopen("out.dat","w") ;
  for( i=0; i<10; i++ )
  {
     fscanf(fp,"%d ", &n);
     place = fun(n);
     fprintf(wf, "%d\n", place);
  }
  fclose(fp) ;
  fclose(wf) ;
}

⣨ʮ
дfun书ǣ㲢3n֮ƽ֮͡
磬Ӽ̸n100Ϊsum148.874270
ע⣺nֵҪ2100ĶmainеκݣںfunĻд䡣

#include <stdio.h>
#include <math.h>
double fun(int n)  
{

}
main()
{
	int n;
	double sum;
    FILE *out;
	printf("Input  n=");
	scanf("%d",&n);
	sum=fun(n);
	printf("\nsum=%f\n",sum);
 /******************************/
	out=fopen("out.dat","w");
	fprintf(out,"%f\n",fun(180));
	fclose(out);
 /******************************/
}

⣨ʮߣ
дfun书ǣλabϲһcСϲķʽǣaʮλ͸ληcʮλǧλϣbʮλ͸ληcİλ͸λϡ
磬a45b12ʱøúc5142
ע⣺ļIN.DATеݲ޸ġ

#include <stdio.h>
void fun(int a,int b,long *c)
{

}
main()
{  int a,b; long c;
   void NONO( );
   printf("Input a, b:");
   scanf("%d%d", &a, &b);
   fun(a,b,&c);
   printf("The result is: %d\n", c);
   NONO();
}
void NONO( )
{/* ڴļݣúݣرļ*/
	FILE *rf, *wf ;
	int i, a,b ; long c ;
	rf=fopen("in.dat", "r");
	wf=fopen("out.dat","w");
	for(i=0;i<10;i++)
	{
	  fscanf(rf, "%d,%d",&a,&b);
	  fun(a, b, &c) ;
	  fprintf(wf,"a=%d,b=%d,c=%ld\n",a,b,c);
	}
	fclose(rf);
	fclose(wf);
}

⣨ʮˣ
дfunúĹǣжַǷΪģǣ1"YES"򷵻0"NO"ָ˳͵һַ
磬ַLEVELǻģַ123312Ͳǻġ
ע⣺ĶmainеκݣںfunĻд䡣

#include <stdio.h>
#define N 80
int fun(char *str)
{

}
main()
{
	char s[N];
	FILE *out;
	char *test[]={"1234321","123421","123321","abcdCBA"};
	int i;
	printf("Enter a string : "); 
	gets(s);
	printf("\n");
	puts(s);
	if(fun(s))
		printf("YES\n");
	else
		printf("NO\n"); 
	 /************************************/
	out=fopen("out.dat","w");
	for(i=0;i<4;i++)
		if(fun(test[i]))
			fprintf(out,"YES\n");
		else
			fprintf(out,"NO\n");
		fclose(out);
	 /************************************/
}

⣨ʮţ
дfunԳΪ7ַַסβַ⣬5ַASCII뽵С磬ԭַΪ"CEAedca"Ϊ"CedcEAa"
ע⣺ĶmainеκݣںfunĻд䡣

#include <stdio.h>
#include <ctype.h>
#include <string.h>
void fun(char *s,int num)
{

}
main()
{
  void NONO( );
  char s[10];
  printf("7ַַ:");
  gets(s);
  fun(s,7);
  printf("\n%s",s);
  NONO();
}
void NONO()
{
/* ڴ˺ڴļݣ fun 
   ݣرļ */
   char s[10] ;
   FILE *rf, *wf ;
   int i = 0 ;
   rf=fopen("in.dat","r") ;
   wf=fopen("out.dat","w") ;
   while(i<10)
   {
	fgets(s,10,rf) ;
	s[7] = 0 ;
       fun(s,7);
       fprintf(wf, "%s\n", s) ;
       i++ ;
   }
   fclose(rf) ;
   fclose(wf) ;
}

⣨ʮ
дfun书ǣһ÷Уȥһ߷ֺһͷ֣Ȼƽֵͨءβaָŵ÷ֵ飬βnдŵ÷ָn>2
磬9.9  8.5  7.6  8.5  9.3  9.5  8.9  7.8  8.6  8.4ʮ÷֣Ϊ8.687500
ע⣺ĶmainеκݣںfunĻд䡣

#include <stdio.h>
void NONO();
double fun(double a[ ],int n)
{

}
main()
{   double  b[10], r; int i;
    printf("10b :  ");
    for (i=0; i<10; i++)   
		scanf("%lf",&b[i]);
    printf("10 :  ");
    for (i=0; i<10; i++)   
		printf("%4.1lf ",b[i]);    
	printf("\n");
	r=fun(b,10);
    printf("ȥ߷ֺͷֺƽ :  %f\n", r );
    NONO();
}
void NONO()
{/* ڴļݣúݣرļ */
  FILE *fp, *wf;
  int i, j ;
  double b[10], r;
  fp = fopen("in.dat","r");
  wf = fopen("out.dat","w");
  for(i = 0 ; i < 10 ; i++)
  {
    for(j = 0 ; j < 10 ; j++) 
	{
      fscanf(fp,"%lf ",&b[j]);
    }
    r = fun(b, 10);
    fprintf(wf, "%f\n", r);
  }
  fclose(fp);
  fclose(wf);
}


























