• R/O
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

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

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


コミットメタ情報

リビジョン124 (tree)
日時2016-02-15 10:00:52
作者bellyoshi

ログメッセージ

(メッセージはありません)

変更サマリ

差分

--- pracC3/full1.c (nonexistent)
+++ pracC3/full1.c (revision 124)
@@ -0,0 +1,18 @@
1+#include <stdio.h>
2+#include <string.h>
3+
4+char first[100];
5+char last[100];
6+char full[200];
7+
8+int main(){
9+ printf("Enter first name: ");
10+ fgets(first, sizeof(first), stdin);
11+ printf("Enter last name: ");
12+ fgets(last, sizeof(last), stdin);
13+ strcpy(full, first);
14+ strcat(full, " ");
15+ strcat(full, last);
16+ printf("The name is %s\n", full);
17+ return 0;
18+}
\ No newline at end of file
--- pracC3/full2.c (nonexistent)
+++ pracC3/full2.c (revision 124)
@@ -0,0 +1,20 @@
1+#include <stdio.h>
2+#include <string.h>
3+
4+char first[100];
5+char last[100];
6+char full[200];
7+
8+int main(){
9+ printf("Enter first name: ");
10+ fgets(first, sizeof(first), stdin);
11+ first[strlen(first)-1] = '\0';
12+ printf("Enter last name: ");
13+ fgets(last, sizeof(last), stdin);
14+ last[strlen(last)-1] = '\0';
15+ strcpy(full, first);
16+ strcat(full, " ");
17+ strcat(full, last);
18+ printf("The name is %s\n", full);
19+ return 0;
20+}
\ No newline at end of file
--- pracC3/xgets.c (nonexistent)
+++ pracC3/xgets.c (revision 124)
@@ -0,0 +1,22 @@
1+#include <stdio.h>
2+
3+FILE *save_file = NULL;
4+FILE *playback_file = NULL;
5+
6+char *extended_fgets(char *line, int size, FILE *file)
7+{
8+ char *result;
9+
10+ if (playback_file != NULL) {
11+ result = fgets(line, size, playback_file);
12+ fputs(line, stdout);
13+ } else {
14+ result = fgets(line,size, file);
15+ }
16+
17+ if (save_file != NULL){
18+ fputs(line, save_file);
19+ }
20+
21+ return result;
22+}
\ No newline at end of file
--- pracC3/p_array.c (nonexistent)
+++ pracC3/p_array.c (revision 124)
@@ -0,0 +1,23 @@
1+#include <stdio.h>
2+int array[3][2];
3+int main(){
4+ int x,y;
5+ array[0][0] = 0 * 10 + 0;
6+ array[0][1] = 0 * 10 + 1;
7+ array[1][0] = 1 * 10 + 0;
8+ array[1][1] = 1 * 10 + 1;
9+ array[2][0] = 2 * 10 + 0;
10+ array[2][1] = 2 * 10 + 1;
11+
12+ printf("%d ", array[0][0]);
13+ printf("%d ", array[0][1]);
14+ printf("\n");
15+ printf("%d ", array[1][0]);
16+ printf("%d ", array[1][1]);
17+ printf("\n");
18+ printf("%d ", array[2][0]);
19+ printf("%d ", array[2][1]);
20+ printf("\n");
21+
22+ return 0;
23+}
\ No newline at end of file
--- pracC3/tri.c (nonexistent)
+++ pracC3/tri.c (revision 124)
@@ -0,0 +1,14 @@
1+#include <stdio.h>
2+char line[100];
3+int height;
4+int width;
5+int area;
6+int main()
7+{
8+ printf("Enter width height? ");
9+ fgets(line, sizeof(line), stdin);
10+ sscanf(line, "%d %d",&width, &height);
11+ area = (width * height) / 2;
12+ printf("The area is %d\n", area);
13+ return 0;
14+}
\ No newline at end of file
--- pracC3/list.txt (nonexistent)
+++ pracC3/list.txt (revision 124)
@@ -0,0 +1,3 @@
1+abc
2+John
3+
--- pracC3/base.c (nonexistent)
+++ pracC3/base.c (revision 124)
@@ -0,0 +1,107 @@
1+/*******************************************************************************
2+* Database --
3+* 非常に単純なデータベースプログラムで
4+* プログラムに記述されたリスト中に名前を探す
5+* 使用方法:
6+* database
7+* プログラムは名前の入力を求める。
8+* 名前を入力すると、その名前がリスト中にあるかどうかを通知する。
9+*
10+* 何も入力しないでリターンキーを押すと終了。
11+********************************************************************************/
12+#define STRING_LENGTH 80
13+#include <stdio.h>
14+#include <string.h>
15+
16+extern FILE *save_file;
17+extern FILE *playback_file;
18+;
19+extern char *extended_fgets(char *, int, FILE *);
20+
21+int main(int argc,char *argv[])
22+{
23+ char name[STRING_LENGTH]; //探し出す名前
24+ char *save_file_name;
25+ char *playback_file_name;
26+
27+ int lookup(char const *const name);//名前を探す
28+
29+ while((argc> 1) && (argv[1][0] == '-')) {
30+ switch(argv[1][1]){
31+ // -S<file> 保存ファイルを指定
32+ case 'S':
33+ save_file_name = &argv[1][2];
34+ save_file = fopen(save_file_name, "w");
35+ if (save_file == NULL){
36+ fprintf(stderr,
37+ "Warning: Unable to open save file %s\n",
38+ save_file_name);
39+ }
40+ break;
41+ case 'P':
42+ playback_file_name = &argv[1][2];
43+ playback_file = fopen(playback_file_name, "r");
44+ if (playback_file == NULL) {
45+ fprintf(stderr,
46+ "Error:Unable to open playback file %s\n",
47+ playback_file_name);
48+ exit(8);
49+ }
50+ break;
51+ default:
52+ fprintf(stderr,"Bad option: %s\n", argv[1]);
53+ exit(8);
54+ }
55+ --argc;
56+ ++argv;
57+ }
58+
59+ while (1) {
60+ printf("Enter name: ");
61+ extended_fgets(name, sizeof(name), stdin);
62+
63+ //リターンキーだけかどうかをチェック
64+ //改行には1文字必要である
65+ if (strlen(name) <= 1){
66+ break;
67+ }
68+
69+ //改行文字を取り除く
70+ name[strlen(name) - 1] = '\0';
71+
72+ if(lookup(name)){
73+ printf("%s is in the list\n", name);
74+ }else{
75+ printf("%s is not in the list\n", name);
76+ }
77+ }
78+ return 0;
79+}
80+/*******************************************************************************
81+* lookup -- リスト中で名前を探す。
82+* パラメータ
83+* name -- 探し出す名前
84+* 戻り値
85+* 1 -- 名前がリストにある。
86+* 0 -- 名前がリストにない。
87+********************************************************************************/
88+int lookup(char const *const name)
89+{
90+ //データベース中の人名リスト
91+ //注:最後は行終端を表すNULL
92+ static char *list[] = {
93+ "John",
94+ "Jim",
95+ "Jane",
96+ "Clyde",
97+ NULL
98+ };
99+
100+ int index;
101+ for (index = 0; list[index] != NULL; ++index){
102+ if(strcmp(list[index], name) == 0){
103+ return 1;
104+ }
105+ }
106+ return 0;
107+}
--- pracC3/double.c (nonexistent)
+++ pracC3/double.c (revision 124)
@@ -0,0 +1,11 @@
1+#include <stdio.h>
2+char line[100];
3+int value;
4+int main()
5+{
6+ printf("Enter a value: ");
7+ fgets(line, sizeof(line), stdin);
8+ sscanf(line, "%d", &value);
9+ printf("Twice %d is %d\n", value, value * 2);
10+ return 0;
11+}
\ No newline at end of file
--- pracC3/array.c (nonexistent)
+++ pracC3/array.c (revision 124)
@@ -0,0 +1,17 @@
1+#include <stdio.h>
2+float data[5];
3+float total;
4+float average;
5+
6+int main()
7+{
8+ data[0] = 34.0;
9+ data[1] = 27.0;
10+ data[2] = 45.0;
11+ data[3] = 82.0;
12+ data[4] = 22.0;
13+ total = data[0] + data[1] + data[2] + data[3] + data[4];
14+ average = total / 5.0;
15+ printf("Total %f Average %f\n", total, average);
16+ return 0;
17+}
\ No newline at end of file