Skip to content

Commit 1791e38

Browse files
committed
add a game(to be continued)
1 parent a8eb424 commit 1791e38

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

c/koishi/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
PROJECT(KOISHI)
2+
CMAKE_MINIMUM_REQUIRED(VERSION 2.9)
3+
INCLUDE_DIRECTORIES(
4+
${CMAKE_BINARY_DIR}/../include
5+
)
6+
AUX_SOURCE_DIRECTORY(
7+
${CMAKE_BINARY_DIR}/../src
8+
DIR_SRC
9+
)
10+
ADD_EXECUTABLE(
11+
koishi
12+
${DIR_SRC}
13+
)

c/koishi/include/koishi.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <string.h>
4+
enum level {
5+
easy=1,
6+
normal,
7+
hard,
8+
extreme
9+
};
10+
enum level getlevet(void);

c/koishi/src/koishi.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "../include/koishi.h"
2+
enum level getlevel(){
3+
enum level l;
4+
printf("please input the level number:\n\
5+
1.easy\n\
6+
2.normal\n\
7+
3.hard\n\
8+
4.extreme\n");
9+
scanf("%d",&l);
10+
return l;
11+
}

c/koishi/src/main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include "../include/koishi.h"
2+
int main(){
3+
char *level[4]={"easy","normal","hard","extreme"};
4+
enum level l;
5+
l=getlevel();
6+
while (l<1||l>4){
7+
printf("the number you input(%d) is not listed\nplease input again:\n",l);
8+
l=getlevel();
9+
}
10+
printf("you choose %d %s\n",l,level[l-1]);
11+
return 0;
12+
}

0 commit comments

Comments
 (0)