This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let doll_of_yen yen = | |
| let rate = 114.32 in | |
| let doll = float_of_int(yen) /. rate in | |
| if int_of_float(doll *. 1000.0) mod 10 < 5 then floor(doll*.100.0)/.100.0 else floor((doll+.0.01)*.100.0)/.100.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let yen_of_doll doll = | |
| let rate = 114.32 in | |
| let yen = doll *. rate in | |
| if (int_of_float(yen *. 10.0) mod 10) < 5 then int_of_float (yen) else int_of_float (yen+.1.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <math.h> | |
| long fact(int n){ | |
| if (n <= 1) { | |
| return 1L; | |
| } else { | |
| return n * fact(n -1); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| int main(){ | |
| int n,i; | |
| printf("n = "); | |
| scanf("%d", &n); | |
| while(n != 1){ | |
| for(i=2;i<=n;i++){ | |
| if(n%i == 0){ | |
| printf("%d ",i); | |
| n /= i; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| int main(){ | |
| int i; | |
| float x,n; | |
| float sum_x = 0.0; | |
| float squared_x = 0.0; | |
| float mean,variance; | |
| printf("n = "); | |
| scanf("%f", &n); | |
| for(i=1;i<=n;i++){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| int main(){ | |
| int n; | |
| int count = 0; | |
| printf("n = "); | |
| if(scanf("%d", &n) != 1) { | |
| puts("Wrong input."); | |
| return 1; | |
| } | |
| while(n != 1){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| int recursion(int n){ | |
| if(n == 1) return 1; | |
| if(n == 2) return 2; | |
| return 3*recursion(n-1)+2*recursion(n-2); | |
| } | |
| int main(){ | |
| int n,i; | |
| printf("n = "); | |
| while(scanf("%d", &n) != 1 || n < 3) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| int main(){ | |
| int i,n; | |
| float c; | |
| printf("c = "); | |
| if(scanf("%f", &c) != 1 || c < 2) { | |
| puts("Wrong input."); | |
| return 1; | |
| } | |
| printf("n = "); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #define maxRow 15 //最大行数 | |
| int main(){ | |
| int n,y,x; //正方行列の大きさ。 | |
| int count = 0; //文字を入れ終わった回数。 | |
| char arr[maxRow][maxRow]; //行列。 | |
| char printChar = 'Z'; //初期位置の文字。ここをYやCにしても動くように対応。 | |
| enum directions { UP,LEFT,DOWN,RIGHT }; | |
| enum directions direction = UP; | |
| printf("n = "); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #define maxRow 15 //最大行数 | |
| int main(){ | |
| int n; //正方行列の大きさ。 | |
| int y = 0; | |
| int x = 0; | |
| int top = 0; //上から数えて何行埋まっているか。文字を右に進みながら入れていき、右端にたどり着けばその行はもう埋まった扱いにする。 | |
| int bottom = 0; //同上。 | |
| int left = 0; //同上。 | |
| int right = 0; //同上。 |