#include <guigui01.h> void G01Main() { int i; for (i = 0; i <= 9; i++) { g01_putc('0' + i); g01_putc(' '); } return; }
0 1 2 3 4 5 6 7 8 9
#include <guigui01.h> void setdec(char *s, int i, int n) { int j; for (j = n - 1; j >= 0; j--) { s[j] = '0' + (i % 10); i /= 10; } return; } void G01Main() { int i; char s[5]; for (i = 0; i <= 999; i++) { setdec(s, i, 3); s[3] = ' '; s[4] = 0; /* 終端に0を入れる */ g01_putstr0(s); } return; }
000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 (中略) 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999
#include <guigui01.h> void setdec(char *s, int i, int n) { int j; for (j = n - 1; j >= 0; j--) { s[j] = '0' + (i % 10); i /= 10; } for (j = 0; j < n - 1; j++) { if (s[j] != '0') break; s[j] = ' '; } return; } void G01Main() { int i; char s[5]; for (i = 0; i <= 999; i++) { setdec(s, i, 3); s[3] = ' '; s[4] = 0; g01_putstr0(s); } return; }
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 (中略) 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999
#include <guigui01.h> void setdec(char *s, int i, int n) { int j; for (j = n - 1; j >= 0; j--) { s[j] = '0' + (i % 10); i /= 10; } for (j = 0; j < n - 1; j++) { if (s[j] != '0') break; s[j] = ' '; } return; } char *skip_space(char *s) { while (*s == ' ') { /* while (A) は for (; A;) と同じ意味 */ s++; } return s; } void G01Main() { int i; char s[5]; for (i = 0; i <= 999; i++) { setdec(s, i, 3); s[3] = ' '; s[4] = 0; g01_putstr0(skip_space(s)); } return; }
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 (中略) 7 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 98 7 988 989 990 991 992 993 994 995 996 997 998 999
#inlude <guigui01.h> void setdec(char *s, int i, int n) { (ex0010.cと同じ内容) } char *skip_space(char *s) { (ex0010.cと同じ内容) } void G01Main() { int i, j = 0; char s[11]; for (i = 0; i <= 100; i++) { j += i; } setdec(s, j, 10); s[10] = 0; g01_putstr0(skip_space(s)); return; }
5050
(This host) = http://osask.net