函式的封裝練習

2021-09-22 10:15:40 字數 1458 閱讀 3504

1.實現乙個函式,列印乘法口訣表,口訣表的行數和列數自己指定,

#define _crt_secure_no_warnings

#include #include void print_kjb(int l)

}int main()

2.使用函式實現兩個數的交換。

#define _crt_secure_no_warnings

#include #include void change(int* p1, int* p2)

int main()

3.實現乙個函式判斷year是不是潤年。

(1)判斷所輸入是否為閏年

#define _crt_secure_no_warnings

#include#includeint r_year(int x)

int main()

(2)判斷所輸入區間是否是閏年

#define _crt_secure_no_warnings

#include#includeint r_year(int x)

void more_r_year(int x, int y)

if (f == 0)

printf("此區間沒有閏年\n");

}int main()

建立乙個陣列, 實現函式init()初始化陣列、 實現empty()清空陣列、 實現reverse()函式完成陣列元素的逆置。

#define _crt_secure_no_warnings

#include#includevoid init(int *p, int sz)

void reverse(int* p, int sz)

}void empty(int *p, int sz)

int main()

5.實現乙個函式,判斷乙個數是不是素數。

(1)判斷單個數字

#define _crt_secure_no_warnings

#include#include#includeint is_prime(int n)

return 1;

}int main()

(2)判斷區間內素數

#define _crt_secure_no_warnings

#include#include#includeint is_prime(int n)

return 1;

}void more_prime(int x, int y)

} if (f == 0)

printf("此區間沒有素數\n");

}int main()

PHP 封裝函式練習

以下是對php函式封裝性的練習,在wamp環境下執行,僅供參考學習 header content type text html charset utf 8 封裝乙個函式可以輸出當前的具體日期時間 function gettime del1,del2,del3 md 星期 arr week retur...

封裝的函式

一 封裝的函式 判斷是否為11121 return bool function is 11121 param arr param key return string function sign arr,key str str.key key return strtoupper md5 str par...

練習封裝jsonp方法

練習封裝jsonp方法 點我傳送資料1 button 點我傳送資料2 button js let button1 document.queryselectorall button 0 let button2 document.queryselectorall button 1 function js...