自分の氏名、学籍番号、login名、学年、座席位置を出力せよ。
stdinから与えられた10進の文字をscanf("%d", ...)
を用いて取得し、数字の各桁の合計を求めよ。
% ./a.out
? 768042
27
2つの文字列を入力し、最初の文字列の中に2つ目の文字列が何度出現するか、重複も考慮にいれ数えよ。
入力にはgets
またはfgets
を用いること。
% ./a.out
? ABABA
? ABA
2
引数として与えられたテキストファイルの最も長い行と最も短い行を出力するプログラムを作成せよ。空行は無視すること。
This is a first line.
The second line is longer.
Third line is not.
This line is a little bit longer.
So, find out the longest one.
% ./a.out a.txt
Longest: line 4
Third line is a little bit longer.
Shortest: line 3
Third line is not.
フィボナッチ数列を40回求める時間を、setitimerを用いてシグナルで計測せよ。
int fib(int n) {
if (n == 0 || n == 1) return 1;
else return fib(n - 1) + fib(n - 2);
}