標(biāo)題: 函數(shù)基礎(chǔ) [打印本頁(yè)]

作者: xiaojuan    時(shí)間: 2014-9-17 14:40
標(biāo)題: 函數(shù)基礎(chǔ)


#include<stdio.h>
#define SPACE ' '
#define A 6

int big (int a, int b);
void hop (char ch, int num);

int main (void)
{
int a, b;

printf ("please input two number :");
printf ("if you want to quit,please enter q\n");

hop (SPACE, A);

while (scanf("%d,%d",&a,&b) == 2)
{
  printf("%d\n",big (a,b));  //或者設(shè)一個(gè)數(shù)=big(a,b)
          //也不可以寫成這樣 big (a,b); leser = min;這樣錯(cuò)誤的,因?yàn)橹骱瘮?shù)不認(rèn)識(shí)第一個(gè)式子
  printf ("please input two number :");
  printf ("if you want to quit,please enter q\n");
}

return 0;
}

void hop (char, int)
{
int count;

for (count=1; count<=A; count++)
  printf ("%c",A);
}

int big (int a, int b)  
{
int max;

if (a>b)
  max = a;
else
  max = b;
return max;
}





作者: xiaojuan    時(shí)間: 2014-9-17 14:41
#include<stdio.h>


int imax (int a, int b)

int main (void)
{
printf ("The maximum of %d and %d is %d.\n",
   3, 5, imax(3));        //error 缺少一個(gè)數(shù)
printf ("The maximum of %d and %d is %d.\n",
   3, 5, imax(3.0,5.0));      //類型不符
return 0;
}
int imax (n, m)
{
int n, m, max;
if (n




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1