# 轉excel ## 今日當值救生員 ```c= #ifndef DUTYLIFEGUARD_H_INCLUDED #define DUTYLIFEGUARD_H_INCLUDED #include <stdio.h> #include <string.h> #include "functions.h" void dutylifeguard(Member members[]) { int id1, id2, id3, id4, confirm; printf("Hired positions (sorted by number): \n"); for (int i = 0; i < MAX_MEMBERS; i++) { if (members[i].hired == 1) { printf("Number: %d, Name: %s\n", members[i].id, members[i].name); } } printf("Enter the number of the person (am): "); scanf("%d%d", &id1, &id2); printf("Enter the number of the person (pm): "); scanf("%d%d", &id3, &id4); printf("confirm?(Yes = 1/No = 0)\n"); printf("am\n%s, %s\npm\n%s, %s\n", members[id1-1].name, members[id2-1].name, members[id3-1].name, members[id4-1].name); scanf("%d", &confirm); if(confirm == 1){ FILE *fp; if ((fp = fopen ("dutylifeguard.xls", "w")) == NULL) { printf("Open File ERROR!\n"); } else{ fprintf(fp, "am\n%s\t%s\npm\n%s\t%s\n", members[id1-1].name, members[id2-1].name, members[id3-1].name, members[id4-1].name); fclose(fp); } } } #endif ``` ![](https://hackmd.io/_uploads/S1SPYlqPn.png) ![](https://hackmd.io/_uploads/B1vFtl9Dh.png) ## 本日入場人數 ```c= #ifndef ADMITTED_H_INCLUDED #define ADMITTED_H_INCLUDED #include <stdio.h> #include <string.h> void admitted(members) { int ams, pms, confirm; printf("Enter the number of the guest (am): "); scanf("%d", &ams); printf("Enter the number of the guest (pm): "); scanf("%d", &pms); printf("confirm?(Yes = 1/No = 0)\n"); printf("am\n%d\npm\n%d\nam+pm=\n%d\n", ams, pms, ams+pms); scanf("%d", &confirm); if(confirm == 1){ FILE *fp; if ((fp = fopen ("admitted.xls", "w")) == NULL) { printf("Open File ERROR!\n"); } else{ fprintf(fp, "am\t\tpm\n%d\t+\t%d\t=%d", ams, pms, ams+pms); fclose(fp); } } } #endif ``` ![](https://hackmd.io/_uploads/BJk3jl5vh.png) ![](https://hackmd.io/_uploads/SyMIRlqDn.png) ## 泳池狀態 ```c= #ifndef POOL_H_INCLUDED #define POOL_H_INCLUDED #include <stdio.h> #include <string.h> void pool(members) { double outpH, inpH, massagepH, outppm, inppm, massageppm, outamtp, outpmtp, inamtp, inpmtp, massageamtp, massagepmtp; int confirm; printf("outdoor pool pH & ppm:"); scanf("%lf %lf", &outpH, &outppm); printf("indoor pool pH & ppm:"); scanf("%lf %lf", &inpH, &inppm); printf("massage pool pH & ppm:"); scanf("%lf %lf", &massagepH, &massageppm); printf("outdoor pool am temperature(¢XC):"); scanf("%lf", &outamtp); printf("outdoor pool pm temperature(¢XC):"); scanf("%lf", &outpmtp); printf("indoor pool am temperature(¢XC):"); scanf("%lf", &inamtp); printf("indoor pool pm temperature(¢XC):"); scanf("%lf", &inpmtp); printf("massage pool am temperature(¢XC):"); scanf("%lf", &massageamtp); printf("massage pool pm temperature(¢XC):"); scanf("%lf", &massagepmtp); printf("confirm?(Yes = 1/No = 0)\n"); printf("outdoor pool\npH:%.1lf ppm:%.1lf am¢XC:%.1lf pm¢XC:%.1lf\nindoor pool\npH:%.1lf ppm:%.1lf am¢XC:%.1lf pm¢XC:%.1lf\nmassage pool\npH:%.1lf ppm:%.1lf am¢XC:%.1lf pm¢XC:%.1lf\n", outpH, outppm, outamtp, outpmtp, inpH, inppm, inamtp, inpmtp, massagepH, massageppm, massageamtp, massagepmtp); scanf("%d", &confirm); if(confirm == 1){ FILE *fp; if ((fp = fopen ("pool.xls", "w")) == NULL) { printf("Open File ERROR!\n"); } else{ fprintf(fp, " \tpH\tppm\tam\tpm\n"); fprintf(fp, "outdoor pool\t %.1lf \t %.1lf \t%.1lf ¢XC\t%.1lf ¢XC\n", outpH, outppm, outamtp, outpmtp); fprintf(fp, "indoor pool\t %.1lf \t %.1lf \t %.1lf ¢XC\t%.1lf ¢XC\n", inpH, inppm, inamtp, inpmtp); fprintf(fp, "massage pool\t %.1lf \t %.1lf \t %.1lf ¢XC\t%.1lf ¢XC\n", massagepH, massageppm, massageamtp, massagepmtp); fclose(fp); } } } #endif ``` ![](https://hackmd.io/_uploads/B1N7qZ9Dn.png) ![](https://hackmd.io/_uploads/SyRQqZqwn.png) ## 物資狀態 順便把輸出改成文字 ```c= #ifndef TOOL_H_INCLUDED #define TOOL_H_INCLUDED #include <stdio.h> #include <string.h> #include "functions.h" void tool(Member members[]) { int firstaidkit, lifebuoy, lifelinebag, whistle, electricfan, confirm, t; printf("Check Tool Status:\n"); printf("First aid kit(0 no problem/1 Need to be replaced/supplemented): "); scanf("%d", &t); if(t==0){ firstaidkit="no problem";} else{ firstaidkit="Need replaced"; } printf("life buoy(0 no problem/1 Need to be replaced/supplemented): "); scanf("%d", &t); if(t==0){ lifebuoy="no problem"; } else{ lifebuoy="Need replaced"; } printf("lifeline bag(0 no problem/1 Need to be replaced/supplemented): "); scanf("%d", &t); if(t==0){ lifelinebag="no problem"; } else{ lifelinebag="Need replaced"; } printf("whistle(0 no problem/1 Need to be replaced/supplemented): "); scanf("%d", &t); if(t==0){ whistle="no problem"; } else{ whistle="Need replaced"; } printf("electric fan(0 no problem/1 Need to be replaced/supplemented): "); scanf("%d", &t); if(t==0){ electricfan="no problem"; } else{ electricfan="Need replaced"; } printf("confirm?(Yes = 1/No = 0)\n"); printf("Tool Status(0 no problem/1 Need to be replaced/supplemented)\nFirst aid kit:%s\nlife buoy:%s\nlifeline bag:%s\nwhistle:%s\nelectric fan:%s\n", firstaidkit, lifebuoy, lifelinebag, whistle, electricfan); scanf("%d", &confirm); if(confirm == 1){ FILE *fp; if ((fp = fopen ("tool.xls", "w")) == NULL) { printf("Open File ERROR!\n"); } else{ fprintf(fp, "Tool Status(0 no problem/1 Need to be replaced/supplemented)\nFirst aid kit\tlife buoy\tlifeline bag\twhistle\tnelectric fan\n%s\t%s\t%s\t%s\t%s\t\n", firstaidkit, lifebuoy, lifelinebag, whistle, electricfan); fclose(fp); } } } #endif ``` ![](https://hackmd.io/_uploads/ByDt0Wqwh.png) ![](https://hackmd.io/_uploads/H1oiAZ9Dh.png)