Skip to content

Commit 0b92f6f

Browse files
committed
新增多个文件,包含基本输入输出逻辑和游戏规则判断
1 parent f7e9d7d commit 0b92f6f

3 files changed

Lines changed: 99 additions & 0 deletions

File tree

niuke/practice/noob/noob53/1.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
int main()
5+
{
6+
int c = 0;
7+
char *str = (char *)malloc(1);
8+
if(NULL == str)
9+
{
10+
return -1;
11+
}
12+
int iLen = 0;
13+
while(1)
14+
{
15+
c = getchar();
16+
if(c == '\n')
17+
{
18+
break;
19+
}
20+
else if(c == '5')
21+
{
22+
c = '*';
23+
}
24+
str[iLen++] = c;
25+
char *temp = (char *)realloc(str,iLen+2);
26+
if(temp == NULL)
27+
{
28+
return -1;
29+
}
30+
str = temp;
31+
}
32+
str[iLen] = '\0';
33+
printf("%s",str);
34+
free(str);
35+
return 0;
36+
}

niuke/practice/noob/noob54/1.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <algorithm>
2+
#include <cmath>
3+
#include <cstdio>
4+
#include <cstdlib>
5+
#include <cstring>
6+
#include <iostream>
7+
#include <string>
8+
typedef long long ll;
9+
using namespace std;
10+
11+
rules = {
12+
"elephant" : 'tiger',
13+
14+
}
15+
16+
int main() {
17+
string str1,str2;
18+
cin >> str1 >> str2;
19+
if(str1 == elephant)
20+
21+
return 0;
22+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import java.util.Scanner;
2+
3+
4+
public class Main{
5+
public static void main(String[] args)
6+
{
7+
Scanner sc = new Scanner(System.in);
8+
String s1 = sc.next();
9+
String s2 = sc.next();
10+
String[] arr = {"elephant","tiger","cat","mouse"};
11+
12+
int a = -1, b = -1;
13+
for(int i = 0;i<arr.length;i++)
14+
{
15+
if(s1.equals(arr[i])){
16+
a = i;
17+
break;
18+
}
19+
}
20+
21+
for(int i = 0;i<arr.length;i++)
22+
{
23+
if(s2.equals(arr[i]))
24+
{
25+
b = i;
26+
break;
27+
}
28+
}
29+
if((a-b == -1) || (a-b == 3))
30+
{
31+
System.out.println("win");
32+
}else if((a-b == 1) || (a-b == -3))
33+
{
34+
System.out.println("lose");;
35+
}else
36+
{
37+
System.out.println("tie");;
38+
}
39+
sc.close();
40+
}
41+
}

0 commit comments

Comments
 (0)