C exercises(f) Final Exam
Categories:
Related Post
C exercises (3) string and ctypeC exercises (3) string and ctype
標準ライブラリ関数 : 文字列操作関数 string.hのヘッダファイルをincludeする 主なもの: strcpy(ss,st):文字列(文字型の配列)ssに文字列stをコピーする strlen(st):文字列stの長さを求める strcat(ss,st):文字列ssの後ろに文字列stを連結する strncpy(ss,st,n):文字列ssに文字列stの先頭n文字をコピーする strncat(ss,st,n)文字列ssの後ろに文字列stの先頭n文字を連結する サンプル: #include <stdio.h> #include <string.h> //string.hのインクルードを忘れずに int main(int argc, const […]
C exercises (4) math and utilityC exercises (4) math and utility
数学関数 数学的な計算が必要な場合に使用する命令セットです。引数と返りは全てdouble型になります。 主なもの: sin(x):角度x(ラジアン)のsinの値を返す cos(x):角度x(ラジアン)のcosの値を返す tan(x):角度x(ラジアン)のtanの値を返す pow(x,y):xのy乗の値を返す exp(x):指数関数eのx乗の値を返す log(x):xの自然対数の値を返す log10(x):xの常用対数の値を返す sqrt(x):xの平方根の値を返す ceil(x):小数第一位を切り捨てした値を返す floor(x):小数第一位を切り上げした値を返す round(x):小数第一位を四捨五入した値を返す サンプル: #include <stdio.h> #include <math.h> //math.hのインクルードを忘れずに […]
C exercises(b) Recursive callC exercises(b) Recursive call
東京魅力PRサークル会員募集中 http://svn.mki.biz/pukiwiki/index.php?u-tokyo 興味があれば、ぜひコメントください。 階乗の計算 皆さんは「階乗の計算」を覚えていますか? 5の階乗なら「5!」と表記し, 5! = 5 × 4 × 3 × 2 × 1 と計算します。つまり答えは120です。 0 の階乗:1 […]