-
Notifications
You must be signed in to change notification settings - Fork 0
/
repo.c
67 lines (53 loc) · 1.57 KB
/
repo.c
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
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#define STUDENT_NAME "黒川良太"
void divide(int x, FILE *fp);
void each_problem(int x, int y, FILE *fp);
int main(void)
{
int number_of_class;
printf("type the number of class -> ");
scanf("%d", &number_of_class);
char dir_path[10], file_path[15];
sprintf(dir_path, "./b%d", number_of_class);
sprintf(file_path, "%s/B%d.txt", dir_path, number_of_class);
if (mkdir(dir_path, 0755) == -1)
{
perror("mkdir error");
}
FILE *fp = fopen(file_path, "w");
if (!fp)
{
fprintf(stderr, "cannot open %s\n", file_path);
return 1;
}
int month, day;
printf("type the month and day -> ");
scanf("%d %d", &month, &day);
fprintf(fp, "科目名: プログラミング実習III\n課題: B%d\n番号: 37022497\n氏名: %s\n作成: 2023/%d/%d\n\n", number_of_class,STUDENT_NAME, month, day);
divide(40, fp);
int number_of_problem;
printf("type the number of problem -> ");
scanf("%d", &number_of_problem);
each_problem(number_of_class, number_of_problem, fp);
fprintf(fp, "[課題 B%d の感想]\n", number_of_class);
fclose(fp);
return 0;
}
void divide(int x, FILE *fp)
{
for (int i = 0; i < x; i++)
{
fprintf(fp, "-");
}
fprintf(fp, "\n");
}
void each_problem(int x, int y, FILE *fp)
{
for (int i = 0; i < y; i++)
{
fprintf(fp, "[課題%d.%d]\n[課題の内容]\n〇〇を作成した。\n\n[実行結果]\n[考察]\n[工夫した箇所]\n", x, i+1);
divide(40, fp);
}
}