Skip to content

Commit

Permalink
日常练习
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunbeam-5 committed Jun 7, 2022
1 parent 348c3df commit ff9ad2c
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 1 deletion.
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions 20220605/src/斐波那契数列.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.Scanner;

public class 斐波那契数列 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
System.out.println(isFibonacci(n));
}
public static int isFibonacci(int n){
int a = 1, b = 1, c = 0;
if (n == 1 || n == 2){
return 1;
}else{
for (int i = 3; i <= n; i++) {
c = a + b;
a = b;
b = c;
}
return c;
}
}
}
21 changes: 21 additions & 0 deletions 20220605/src/递归打印数字的每一位.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import java.util.Scanner;

public class 递归打印数字的每一位 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
func1(n);
}
public static int[] func1(int n){
int i = 0;
int[] arr = new int[100];
if (n < 10){
arr[i] = n;
return arr;
}else{
arr[i] = n % 10;
i++;
return n /= 10;
}
}
}
2 changes: 1 addition & 1 deletion 20220605/src/递归返回的数字之和.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static int func(int n){
if (n <= 9){
return n;
}else {
return
return n % 10 + func(n / 10);
}
}
}
3 changes: 3 additions & 0 deletions 20220607/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions 20220607/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions 20220607/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions 20220607/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions 20220607/20220607.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
42 changes: 42 additions & 0 deletions 20220607/src/自己造一个对象.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
public class 自己造一个对象 {
class girlfriend{
public String name;
public String Englishname;
public int age;
public int height;
public int weight;
public String number;
public String address;

public void responde1(){
System.out.println("早安");
}
public void responde2(){
System.out.println("午安");
}
public void responde3(){
System.out.println("晚安");
}
public void responde4(){
System.out.println("啊哈哈哈哈哈哈,憨憨");
}
public void responde5(){
System.out.println("小狐狸~");
}
public void responde6(){
System.out.println("憨批");
}
}
public static void main(String[] args) {
girlfriend the_little_prince = new girlfriend();
the_little_prince.name = "绾";
the_little_prince.Englishname = "Isbella";
the_little_prince.age = 19;
the_little_prince.height = 168;
the_little_prince.weight = 103;
the_little_prince.number = "62";
the_little_prince.address = "CA";

the_little_prince.responde1();
}
}

0 comments on commit ff9ad2c

Please sign in to comment.