From f485cf09056a6d3fe7188137a64d21709511920f Mon Sep 17 00:00:00 2001 From: Sunny Wang Date: Fri, 16 Nov 2018 20:02:16 -0500 Subject: [PATCH 1/3] first commit --- programs/Java/substring_string.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 programs/Java/substring_string.java diff --git a/programs/Java/substring_string.java b/programs/Java/substring_string.java new file mode 100644 index 0000000..63da8b8 --- /dev/null +++ b/programs/Java/substring_string.java @@ -0,0 +1,27 @@ +package substring; + +import java.util.Scanner; + +public class substring_string { + public static void main(String[] args) { + + String stringis, substringis; + char option; + Scanner input = new Scanner(System.in); + + System.out.print("Please intput a string: "); + stringis = input.nextLine(); + + System.out.print("Please intput a substring: "); + substringis = input.nextLine(); + + if (stringis.contains(substringis)) { + System.out.println(stringis + " contains " + substringis); + } + else { + System.out.println("Result no found!"); + } + + System.out.println("Good bye!"); + } +} From 03fe170a7c095af1f224438aadcad0e0956a355f Mon Sep 17 00:00:00 2001 From: Sunny Wang Date: Fri, 16 Nov 2018 22:21:51 -0500 Subject: [PATCH 2/3] first commit --- programs/C/factorial.c | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 programs/C/factorial.c diff --git a/programs/C/factorial.c b/programs/C/factorial.c new file mode 100644 index 0000000..fff5a56 --- /dev/null +++ b/programs/C/factorial.c @@ -0,0 +1,68 @@ +#include +int main() +{ + int choose = 0, n, i; + unsigned long long factorial = 1; + + while (choose !=3){ + factorial = 1; + + printf("Type number to choose \n 1. factorial \n 2. double factorial \n 3.Exit\n Choice: "); + scanf("%d", &choose); + + switch(choose){ + + case(1): + printf("Enter an integer: "); + scanf("%d",&n); + + if (n > 0){ + for(i=1; i<=n; ++i) + { + factorial *= i; //n! = n*(n-1)... + } + } + else if( n = 0){ + factorial = 1; //0!=1; + } + else // show error if the user enters a negative integer + { + printf("Error! Factorial of a negative number doesn't exist."); + } + printf(" %d!= %llu\n", n, factorial); + + break; + + case(2): + printf("Enter an integer: "); + scanf("%d",&n); + + if (n > 0){ + for(i=n; i>=1; i-=2) + { + factorial *= i; //n! = n*(n-1)... + } + } + else if( n = 0){ + factorial = 1; //0!=1; + } + else // show error if the user enters a negative integer + { + printf("Error! Double Factorial of a negative number doesn't exist."); + } + printf(" %d!!= %llu\n", n, factorial); + + break; + + case(3): + printf("Good bye!\n"); + + break; + + default: + printf("Invalid number, please choose again."); + } + +} + return 0; +} From 631ab066a1cba95413f3f1ce3349fa6ea4f3ece2 Mon Sep 17 00:00:00 2001 From: Sunny Wang Date: Fri, 16 Nov 2018 22:28:23 -0500 Subject: [PATCH 3/3] first commit --- programs/Java/substring_string.java | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 programs/Java/substring_string.java diff --git a/programs/Java/substring_string.java b/programs/Java/substring_string.java deleted file mode 100644 index 63da8b8..0000000 --- a/programs/Java/substring_string.java +++ /dev/null @@ -1,27 +0,0 @@ -package substring; - -import java.util.Scanner; - -public class substring_string { - public static void main(String[] args) { - - String stringis, substringis; - char option; - Scanner input = new Scanner(System.in); - - System.out.print("Please intput a string: "); - stringis = input.nextLine(); - - System.out.print("Please intput a substring: "); - substringis = input.nextLine(); - - if (stringis.contains(substringis)) { - System.out.println(stringis + " contains " + substringis); - } - else { - System.out.println("Result no found!"); - } - - System.out.println("Good bye!"); - } -}