Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef enum{
- off, on
- } binary;
- typedef struct{
- binary denki;
- } heya;
- void turn(heya *s) {
- if (s->denki == off) s->denki = on;
- else s->denki = off;
- }
- void suitti(heya *sinsitu)
- {
- if (sinsitu->denki == on) {
- printf("点灯\n");
- turn(sinsitu);
- } else {
- printf("消灯\n");
- turn(sinsitu);
- }
- }
- int main()
- {
- heya *sinsitu;
- sinsitu = (heya *) malloc(sizeof(heya));
- sinsitu->denki = on;
- suitti(sinsitu);
- suitti(sinsitu);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement