#ifndef _INCLUDE_MAIN_
#define _INCLUDE_MAIN_
int sum(int min,int max);
extern int Public;
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int nezumi();
int static_int();
void increment_int(int *pvalue);
int getaverage1(int data[]);
int getaverage2(int *data);
typedef struct {
int year;
int clas;
int number;
char name[64];
double stature;
double weight;
} student;
void showStudent(student *student);
void showStudents(student[], int count);
int main(int argc, const char *argv[]) {
printf("Hello, World!\nhoge\n");
for (int i = 0, l = 100; i < l; i++) {
printf("print %d", i);
if (i >= 10) {
printf("break : %d", i);
break;
}
}
printf("もらったお小遣いの合計が100万円を超えるのは%d月目です\n", nezumi());
static_int();
static_int();
static_int();
static_int();
printf("%d\n", static_int());
int array[] = {1, 3, 3, 3, 3, 3, 4};
for (int i = 0, l = sizeof(array) / sizeof(array[0]); i < l; i++) {
printf("%d\t", array[i]);
}
printf("\n");
char str[] = "MARIO";
{
int *p, i;
p = &i;
if (p == NULL) {
}
*p = 10;
increment_int(&i);
increment_int(&*p);
printf("%d\n", i);
}
{
student s1;
s1.clas = 1;
}
{
FILE *file;
file = fopen("test.txt", "a+");
for (int i = 0; i < 10; i++) {
fprintf(file, "hoge %d \n", i);
}
fclose(file);
}
{
int *heap;
heap = (int *)malloc(sizeof(int) * 10);
if (heap == NULL) {
exit(1);
}
for (int i = 0; i < 10; i++) {
heap[i] = i;
}
printf("%d\n", heap[3]);
free(heap);
}
{
printf("hoge\n");
student *students;
students = (student *)malloc(sizeof(student) * 10);
if (students == NULL) {
exit(1);
}
students = (student *)realloc(students, sizeof(student) * 100);
for (int i = 0, l = 100; i < l; i++) {
}
for (int i = 0, l = 100; i < l; i++) {
}
free(students);
}
{
student stu;
stu.clas = 1;
strcpy(stu.name, "mario");
stu.number = 1;
stu.stature = 1.3;
stu.weight = 4.4;
stu.year = 2004;
showStudent(&stu);
student stu2;
strcpy(stu2.name, "ruiji");
student students[] = {stu, stu2};
showStudents(students, sizeof(students) / sizeof(student));
printf("class %d\n", students[1].clas);
}
return 0;
}
void showStudent(student *stu) { printf("%s\n", (*stu).name); }
void showStudents(student students[], int count) {
for (int i = 0; i < count; i++) {
printf("%s\n", students[i].name);
students[i].clas = i * 10;
}
}
int nezumi() {
int sum = 0, tuki = 1, okodukai = 1;
while (sum < 1000000) {
sum += okodukai;
okodukai *= 2;
tuki++;
}
return tuki;
}
int static_int() {
static int hoge = 0;
hoge++;
return hoge;
}
void increment_int(int *pvalue) {
(*pvalue)++;
return;
}