-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//package Main; | ||
|
||
/** | ||
* | ||
* @Explain(说明):字符串首字母大小写转换工具类 | ||
* @time(时间):2019/04/17 | ||
* @role(谁):杨木发 | ||
* @modify(修改) | ||
* @time: | ||
* @role: | ||
*/ | ||
|
||
|
||
public class InitialsTransformation { | ||
public static void main(String[] args) { | ||
System.out.println(StringUtilMax.initcap("yangmufa")) ; | ||
System.out.println(StringUtilMin.initcap1("YANGMUFA")) ; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
class StringUtilMax{ | ||
public static String initcap(String str){ | ||
//如果字符串str为null和""则返回原数据 | ||
if (str==null||"".equals(str)){ | ||
return str ; | ||
} | ||
|
||
if(str.length()==1){ | ||
//如果字符串str的长度为1,则调用专门把字符串转换为大写的string方法tuUpperCase() | ||
return str.toUpperCase() ; | ||
} | ||
//用字符串截取方法subString()截取第一个字符并调用toUpperCase()方法把它转换为大写字母 | ||
//再与从str第二个下标截取的字符串拼接 | ||
return str.substring(0,1).toUpperCase()+str.substring(1) ; | ||
} | ||
} | ||
|
||
|
||
class StringUtilMin{ | ||
public static String initcap1(String str){ | ||
//如果字符串str为null和""则返回原数据 | ||
if (str==null||"".equals(str)){ | ||
return str ; | ||
} | ||
|
||
if(str.length()==1){ | ||
//如果字符串str的长度为1,则调用专门把字符串转换为小写的string方法tuUpperCase() | ||
return str.toLowerCase() ; | ||
} | ||
//用字符串截取方法subString()截取第一个字符并调用toUpperCase()方法把它转换为小写字母 | ||
//再与从str第二个下标截取的字符串拼接 | ||
return str.substring(0,1).toLowerCase()+str.substring(1) ; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
大小写转换 | ||
**/ | ||
import java.util.Scanner; | ||
|
||
class TestChange | ||
{ | ||
public static void main(String[] args) | ||
{ | ||
Scanner sc = new Scanner(System.in); | ||
String str1 = sc.nextLine(); | ||
System.out.println(changeStr(str1)); | ||
} | ||
|
||
public static String changeStr(String str){ | ||
|
||
char[] c = str.toCharArray(); //先将字符串转换成字符数组 | ||
int value = 'a'-'A'; //计算大小写间差值:32 | ||
|
||
//循环遍历字符数组 | ||
for(int i = 0; i < c.length; i++){ | ||
if('a'<=c[i] && c[i] <='z'){ | ||
c[i] = (char)(c[i]-value); //小写变大写 | ||
}else if('A'<=c[i] && c[i] <='Z'){ | ||
c[i] = (char)(c[i]+value); //大写变小写 | ||
} | ||
} | ||
|
||
String laststr = new String(c); //再将字符数组转换成字符串 | ||
return laststr; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class 找出出现一次的数字 { | ||
public static void main(String[] args) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import java.util.Scanner; | ||
|
||
public class 求和的重载 { | ||
public static void main(String[] args) { | ||
int a = 10, b = 20; | ||
double x = 6.4, y = 3.2, z = 5.2; | ||
int sum1 = add(a,b); | ||
double sum2 = add(x,y,z); | ||
System.out.println(sum1); | ||
System.out.println(sum2); | ||
} | ||
public static int add(int a, int b){ | ||
return a+b; | ||
} | ||
public static double add(double a, double b, double c){ | ||
return a+b+c; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import java.util.Scanner; | ||
|
||
public class 求阶乘和 { | ||
public static void main(String[] args) { | ||
Scanner sc = new Scanner(System.in); | ||
int n = sc.nextInt(); | ||
int ret = func(n); | ||
System.out.println(ret); | ||
} | ||
|
||
public static int func(int n){ | ||
int sum = 0, a = 1; | ||
for (int i = 1; i <= n; i++) { | ||
a *= i; | ||
sum += a; | ||
} | ||
return sum; | ||
} | ||
} |