• R/O
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

練習用です。いろんなものがごちゃまぜです。


Commit MetaInfo

Revision20 (tree)
Time2015-08-22 15:30:10
Authorbellyoshi

Log Message

Change Summary

Incremental Difference

--- vs2015/3_1/kadai/kadai/kadai.c (revision 19)
+++ vs2015/3_1/kadai/kadai/kadai.c (revision 20)
@@ -1,12 +1,14 @@
11 #include <stdio.h>
2+#include <stdlib.h>
23
3-int main(int argc, int argv[]) {
4+int main(int argc, char *argv[]) {
45 if (argc != 2) {
56 printf("使用方法 2の2乗3乗4乗・・・表示する場合:%s 2\n", argv[0]);
67 return 1;
78 }
8- int basenum = atoi(argv[1]);
99
10+ double basenum = atof(argv[1]);
11+
1012 if (-1 == basenum) {
1113 //無限につづく
1214 printf("-1 1 -1 1 -1 ・・・\n");
@@ -21,14 +23,18 @@
2123
2224 if (-1 < basenum && basenum < 1){
2325 //だんだん小さくなる。
24- printf("%d", basenum);
25- return 1;
26+ double pownum = basenum;
27+ do {
28+ printf("%f", pownum);
29+ pownum *= basenum;
30+ } while (pownum > 0.00000000000001);
31+ return 0;
2632 }
2733
28- int pownum = basenum;
34+ double pownum = basenum;
2935
3036 while (pownum < 100000000) {
31- printf("%d ", pownum);
37+ printf("%0.0f ", pownum);
3238 pownum *= basenum;
3339 }
3440