first HW
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
|||||||
|
### IntelliJ IDEA ###
|
||||||
|
out/
|
||||||
|
!**/src/main/**/out/
|
||||||
|
!**/src/test/**/out/
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
bin/
|
||||||
|
!**/src/main/**/bin/
|
||||||
|
!**/src/test/**/bin/
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
Generated
+5
@@ -0,0 +1,5 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="23" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/HW1.iml" filepath="$PROJECT_DIR$/HW1.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+7
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/Hw1" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -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>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import java.util.Scanner;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
public class EvenSum {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int Even_sum(ArrayList<Integer> a) {
|
||||||
|
|
||||||
|
int sum = 0;
|
||||||
|
for (int i = 0; i <= a.size(); i += 2) sum += a.get(i);
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
public static ArrayList<Integer> primefactor(int a) {
|
||||||
|
|
||||||
|
ArrayList<Integer> pf = new ArrayList<Integer>();
|
||||||
|
for (int i = 2; i < a/2; i++ )
|
||||||
|
if(a%i==0){
|
||||||
|
pf.add(i);
|
||||||
|
a/=i;
|
||||||
|
}
|
||||||
|
return pf;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
public class Factorial {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int a = 3,b=6;
|
||||||
|
reco2(a);
|
||||||
|
|
||||||
|
}
|
||||||
|
public static int factorial(int a){
|
||||||
|
/*
|
||||||
|
if (a!=int){
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
else {
|
||||||
|
if (a==1||a==0)
|
||||||
|
return 1;
|
||||||
|
return a*factorial(a-1);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
when n is bigger than max stack:
|
||||||
|
use normal algo
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
public class Fibobin {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
public static int fib(int i){
|
||||||
|
int[] a = {1,1};
|
||||||
|
if(i==1||i==2)
|
||||||
|
return 1;
|
||||||
|
for(int j=3;j<=i;j++){
|
||||||
|
int temp = a[1];
|
||||||
|
a[1] = a[0]+a[1];
|
||||||
|
a[0] = temp;
|
||||||
|
}
|
||||||
|
return a[1];
|
||||||
|
}
|
||||||
|
public static short bin(int i){
|
||||||
|
if(i==0)return 0;
|
||||||
|
if(i==1)return 1;
|
||||||
|
return (short)(bin(i/2)+i%2);
|
||||||
|
}
|
||||||
|
public static boolean fibobin(int n){
|
||||||
|
int i = 1;
|
||||||
|
while(true){
|
||||||
|
int z = fib(i)+bin(fib(i));
|
||||||
|
if(n==z)return true;
|
||||||
|
if(n<z)return false;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
||||||
|
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
||||||
|
public class HelloWorld {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("Hello, World!");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import java.util.Scanner;
|
||||||
|
public class Palindrome {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void palindrome() {
|
||||||
|
Scanner s = new Scanner(System.in);
|
||||||
|
String input = s.next();
|
||||||
|
|
||||||
|
for(int i = 0; i < input.length()/2-1; i++) {
|
||||||
|
if(input.charAt(i)!=input.charAt(input.length()-i-1)) System.out.println("riddy");return;}
|
||||||
|
System.out.println("palindrome");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user