第一题
//main.c
#include
int main(void)
{ int a=5,b=6;
int c;
//int h[9]={1,2,3,4,5,6,7,8,9};
int d;
//int a[]={0,1,2,3,4,5,6,7,8,9};
int m,n,q;
unsigned long w;
//1
printf("即¡ä将?调Ì¡Â用®?func!\n");
printf("传ä?递ÌY给?处ä|理¤¨ª前¡ã的Ì?参?数ºy是º?%d,%d\n",a,b);
func(&a,&b);
printf("退ª?出?func!");
//func.c
#include
void func(int *a, int *b)
{
int temp=*a;
*a=*b;
*b=temp;
}
//func.h
void func(int *a, int *b);
第二题
//main.c
int main(void)
{ int a=5,b=6;
int c;
//int h[9]={1,2,3,4,5,6,7,8,9};
int d;
//int a[]={0,1,2,3,4,5,6,7,8,9};
int m,n,q;
unsigned long w;
//1
printf("即¡ä将?调Ì¡Â用®?func!\n");
printf("传ä?递ÌY给?处ä|理¤¨ª前¡ã的Ì?参?数ºy是º?%d,%d\n",a,b);
func(&a,&b);
printf("退ª?出?func!");
//2
printf("传ä?递ÌY给?处ä|理¤¨ª后¨®的Ì?参?数ºy是º?%d,%d\n",a,b);
//func.c
#include
void func(int *a, int *b)
{
int temp=*a;
*a=*b;
*b=temp;
}
//func.h
void func(int *a, int *b);
第三题
int main(void)
{ int a=5,b=6;
int c;
//int h[9]={1,2,3,4,5,6,7,8,9};
int d;
//int a[]={0,1,2,3,4,5,6,7,8,9};
int m,n,q;
unsigned long w;
//1
printf("即¡ä将?调Ì¡Â用®?func!\n");
printf("传ä?递ÌY给?处ä|理¤¨ª前¡ã的Ì?参?数ºy是º?%d,%d\n",a,b);
func(&a,&b);
printf("退ª?出?func!");
//2
printf("传ä?递ÌY给?处ä|理¤¨ª后¨®的Ì?参?数ºy是º?%d,%d\n",a,b);
//3
c=gcd(a,b);
printf("a和¨ªb的Ì?最Á?大䨮公?约?数ºy为a:êo%d\n", c);
//gcd.c
#include
int gcd(int a,int b)
{
while ((a-b)!= 0)
{
if (a > b)a =a- b;
else b =b- a;
}
return a;
}
//gcd.h
int gcd(int a,int b);
第四题
int main(void)
{ int a=5,b=6;
int c;
//int h[9]={1,2,3,4,5,6,7,8,9};
int d;
//int a[]={0,1,2,3,4,5,6,7,8,9};
int m,n,q;
unsigned long w;
//1
printf("即¡ä将?调Ì¡Â用®?func!\n");
printf("传ä?递ÌY给?处ä|理¤¨ª前¡ã的Ì?参?数ºy是º?%d,%d\n",a,b);
func(&a,&b);
printf("退ª?出?func!");
//2
printf("传ä?递ÌY给?处ä|理¤¨ª后¨®的Ì?参?数ºy是º?%d,%d\n",a,b);
//3
c=gcd(a,b);
printf("a和¨ªb的Ì?最Á?大䨮公?约?数ºy为a:êo%d\n", c);
//4
printf("输º?入¨?你?要°a查¨¦找¨°的Ì?数ºy下?标À¨º为a:");
scanf_s("%d", &d);
arr(d);
//arr.c
#include
int arr(int x)
{
int a[]={2,3,4,5,6,7,8,9,10};
int i=0;
for(i;i<9;i++){
if(a[i]== x )
{
printf("你?要°a查¨¦找¨°的Ì?数ºy为a:êo%d\n",i);
return 0;
}
}
printf("数ºy组Á¨¦中D没?有®D此ä?数ºy");
}
//arr.h
int arr(int x);
第五题
int main(void)
{ int a=5,b=6;
int c;
//int h[9]={1,2,3,4,5,6,7,8,9};
int d;
//int a[]={0,1,2,3,4,5,6,7,8,9};
int m,n,q;
unsigned long w;
//1
printf("即¡ä将?调Ì¡Â用®?func!\n");
printf("传ä?递ÌY给?处ä|理¤¨ª前¡ã的Ì?参?数ºy是º?%d,%d\n",a,b);
func(&a,&b);
printf("退ª?出?func!");
//2
printf("传ä?递ÌY给?处ä|理¤¨ª后¨®的Ì?参?数ºy是º?%d,%d\n",a,b);
//3
c=gcd(a,b);
printf("a和¨ªb的Ì?最Á?大䨮公?约?数ºy为a:êo%d\n", c);
//4
printf("输º?入¨?你?要°a查¨¦找¨°的Ì?数ºy下?标À¨º为a:");
scanf_s("%d", &d);
arr(d);
//5
//int a[]={2,3,4,5,6,7,8,9};
//int m,n;
printf("输º?入¨?f你?要°a查¨¦找¨°的Ì?数ºy下?标À¨º为a:");
scanf_s("%d",&m);
n=biSearch(10,m);
if (n==-1)
printf("没?找¨°到Ì?");
else
printf("%d的Ì?下?标À¨º是º?%d\n",m,n);
//biSearch.c
int biSearch(int len,int x)
{
int a[10]={2,3,4,5,6,7,8,9,10};
int i;
for (i=0;i { if (x==a[i]) return i; } return -1; } //biSearch.h int biSearch(int len,int x); 第六题 int main(void) { int a=5,b=6; int c; //int h[9]={1,2,3,4,5,6,7,8,9}; int d; //int a[]={0,1,2,3,4,5,6,7,8,9}; int m,n,q; unsigned long w; //1 printf("即¡ä将?调Ì¡Â用®?func!\n"); printf("传ä?递ÌY给?处ä|理¤¨ª前¡ã的Ì?参?数ºy是º?%d,%d\n",a,b); func(&a,&b); printf("退ª?出?func!"); //2 printf("传ä?递ÌY给?处ä|理¤¨ª后¨®的Ì?参?数ºy是º?%d,%d\n",a,b); //3 c=gcd(a,b); printf("a和¨ªb的Ì?最Á?大䨮公?约?数ºy为a:êo%d\n", c); //4 printf("输º?入¨?你?要°a查¨¦找¨°的Ì?数ºy下?标À¨º为a:"); scanf_s("%d", &d); arr(d); //5 //int a[]={2,3,4,5,6,7,8,9}; //int m,n; printf("输º?入¨?f你?要°a查¨¦找¨°的Ì?数ºy下?标À¨º为a:"); scanf_s("%d",&m); n=biSearch(10,m); if (n==-1) printf("没?找¨°到Ì?"); else printf("%d的Ì?下?标À¨º是º?%d\n",m,n); //6 printf("请?输º?入¨?楼£¤梯¬Y的Ì?阶¡Á数ºy:"); scanf_s("%d",&q); w=cou(q); printf("有®D%d种?爬¨¤楼£¤梯¬Y的Ì?方¤?法¤¡§\n",w); //taijie.c unsigned long cou (int n) { unsigned long f; if(n==1) f=1; else if(n==2) f=2; else f=cou(n-1)+cou(n-2); return(f); } // taijie.h unsigned long cou (int n);