課程
/后端開發(fā)
/C
/C語言入門
一維數(shù)組中如果給定一個n表示數(shù)組中數(shù)的個數(shù),那后邊要怎么定義。具體步驟怎么寫?
2016-10-13
源自:C語言入門 6-5
正在回答
//這里是輸出最大值的具體步驟
#include<stdio.h>#define N 10 //輸入數(shù)據(jù)量即數(shù)組n的值int Find_Max(const arr[], int n);int main(void){?int i;?int arr[N];?printf("請輸入一組數(shù)據(jù)\n");?for(i=0;i<N;i++)?{??scanf("%d",&arr[i]);?}?printf("max=%d\n",Find_Max(arr,N));?return 0;}int Find_Max(const arr[],int n){?int i;?int max;?max=arr[0];?for(i=1;i<n;i++)?{??if(max<arr[i])??max=arr[i];?}?return max;}
/* Note:Your choice is C IDE */
#include "stdio.h"
#define size n
void main
{
? ? ? int a[size]; ? ? ? /*數(shù)組類型 ? 數(shù)組名【數(shù)組長度】*/
}
舉報
C語言入門視頻教程,帶你進入編程世界的必修課-C語言
2 回答二維數(shù)組的定義
2 回答數(shù)組怎么定義
3 回答二維數(shù)組定義
1 回答函數(shù)定義時,數(shù)組參數(shù)
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-11-01
//這里是輸出最大值的具體步驟
#include<stdio.h>
#define N 10 //輸入數(shù)據(jù)量即數(shù)組n的值
int Find_Max(const arr[], int n);
int main(void)
{
?int i;
?int arr[N];
?printf("請輸入一組數(shù)據(jù)\n");
?for(i=0;i<N;i++)
?{
??scanf("%d",&arr[i]);
?}
?printf("max=%d\n",Find_Max(arr,N));
?return 0;
}
int Find_Max(const arr[],int n)
{
?int i;
?int max;
?max=arr[0];
?for(i=1;i<n;i++)
?{
??if(max<arr[i])
??max=arr[i];
?}
?return max;
}
2016-10-14
/* Note:Your choice is C IDE */
#include "stdio.h"
#define size n
void main
{
? ? ? int a[size]; ? ? ? /*數(shù)組類型 ? 數(shù)組名【數(shù)組長度】*/
}