當前位置:編程學習大全網 - 編程軟體 - C語言求三個數的最大值,看看我哪裏寫錯了?

C語言求三個數的最大值,看看我哪裏寫錯了?

在聲明變量時,可以這麽寫:

int x, y, z;

壹下子聲明了3個int型的變量

但是在定義函數的輸入參數時,後面兩個參數的類型就不能省略了,

int max(int x, y, z);

改為:

int max(int x, int y, int z);

另外,妳在主函數main函數中指定參數是錯誤的,這裏不需要參數:

#include "stdafx.h"

int main ( ) //int a,int b,int c這3個參數不需要

{

int a,b,c; //這3個變量的聲明放在main函數內部

int max(int x,int y,int z);//改為int x,int y,int z

scanf("%d %d %d", &a, &b, &c);

printf("max=%d\n",max(a, b, c));

return 1;

}

int max(int x,int y,int z)//改為int x,int y,int z

{

int temp;

temp=x;

if (x<y)

temp=y;

if (temp<z)

temp=z;

return temp;

}

  • 上一篇:關於matlab中音頻的批量讀取,我感覺應該直接用wavread能讀,就是和dir壹起,但是我不知道怎麽寫,在線等
  • 下一篇:Linuxshell編程問題
  • copyright 2024編程學習大全網