diff --git a/# HacktoberFest2018_chimdolin_come b/# HacktoberFest2018_chimdolin_come new file mode 100644 index 00000000..a9a89827 --- /dev/null +++ b/# HacktoberFest2018_chimdolin_come @@ -0,0 +1,2 @@ +# HacktoberFest2018_chimdolin_come +# HacktoberFest2018_chimdolin_come diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index fd958ab4..00000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..135767fc --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..af15b9b9 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + 1539458719209 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1-0_knapsack_problem/0-1_knapsack.cpp b/1-0_knapsack_problem/0-1_knapsack.cpp new file mode 100644 index 00000000..a88dfee9 --- /dev/null +++ b/1-0_knapsack_problem/0-1_knapsack.cpp @@ -0,0 +1,35 @@ +//0-1 Knapsack problem using dynamic programming +#include + +int max(int a, int b) { return (a > b)? a : b; } + +int knapSack(int W, int wt[], int val[], int n) +{ + int i, w; + int K[n+1][W+1]; + + for (i = 0; i <= n; i++) + { + for (w = 0; w <= W; w++) + { + if (i==0 || w==0) + K[i][w] = 0; + else if (wt[i-1] <= w) + K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]); + else + K[i][w] = K[i-1][w]; + } + } + + return K[n][W]; +} + +void main() +{ + int val[] = {50, 110, 115}; + int wt[] = {10, 20, 30}; + int W = 50; + int n = 1; + int c=knapSack(W, wt, val, n); + cout<0 and j>0 : + if v[i][j] != v[i-1][j] : + print(str(weight[i-1])+"\t\t\t"+str(value[i-1])) + print_items(i-1, v[i-1].index(v[i][j]-value[i-1])) + else : + print_items(i-1, j) + + +def knapsack(): + for i in range(1, n): + for j in range(1, max_wt+1): + if j-weight[i-1] >= 0 : + v[i][j] = max([v[i-1][j], v[i-1][j-weight[i-1]]+value[i-1]]) + else : + v[i][j] = v[i-1][j] + print("Selected Weight\t\tValue") + print_items(n-1, max_wt) + print("\nMaximum Value : "+str(v[n-1][max_wt])) + +knapsack() \ No newline at end of file diff --git a/1-0_knapsack_problem/matrix_chain_mul.cpp b/1-0_knapsack_problem/matrix_chain_mul.cpp new file mode 100644 index 00000000..1b3c13df --- /dev/null +++ b/1-0_knapsack_problem/matrix_chain_mul.cpp @@ -0,0 +1,34 @@ + +//chain matrix multiplication using recursion +#include + +int Order(int m[], int i, int j) +{ + if(i == j) + return 0; + int k; + int min=0; + int count; + + for (k = i; k + +int main(){ + int st1[8]={2,4,7,4,8,5,5,2},st2[8]={3,2,7,5,2,4,1,1},st3[8]={2,4,4,1,5,1,2,4},st4[8]={3,2,5,4,3,2,1,3}; + int i,st1f,st2f,st3f,st4f; +/* printf("Enter st1: "); + for(i=0;i<8;i++) + scanf("%d",&st3[i]); +*/ + printf("ST1 : "); + for(i=0;i<8;i++){ + printf("%d ",st1[i]); + } + printf("\nST2 : "); + for(i=0;i<8;i++){ + printf("%d ",st1[i]); + } + printf("\nST3 : "); + for(i=0;i<8;i++){ + printf("%d ",st1[i]); + } + printf("\nST4 : "); + for(i=0;i<8;i++){ + printf("%d ",st1[i]); + } + printf("\nEnter fitness functions of st1, st2, st3 and st4 : "); + scanf("%d%d%d%d",&st1f,&st2f,&st3f,&st4f); + printf("Fitness function :\n st1=%d\t st2=%d\t st3=%d\t st4=%d ",st1f,st2f,st3f,st4f); + + return 0; + +} diff --git a/ArrayToArrayList.java b/ArrayToArrayList.java index 186631ad..cf233a9f 100644 --- a/ArrayToArrayList.java +++ b/ArrayToArrayList.java @@ -16,9 +16,7 @@ public static void main(String args[]) ArrayList ar=new ArrayList<>(Arrays.asList(i)); ar.add(54889); System.out.println(ar); - - - + } } diff --git a/BigInteger_InJava/Demo.java b/BigInteger_InJava/Demo.java index fc619887..95058e68 100644 --- a/BigInteger_InJava/Demo.java +++ b/BigInteger_InJava/Demo.java @@ -16,6 +16,12 @@ public static void main(String[] args) { BigInteger bigNum = new BigInteger("100000000000000000000000"); long temp = 1235678900; + /*Some constants also be defined in BigInteger such as*/ + + BigInteger bI = BigInteger.TEN; // some other constants are BigInteger.ONE and BigInteger.ZERO + + //------------------------------------------------------ + System.out.println("Added value : " + bigNum.add(BigInteger.valueOf(temp))); System.out.println("Multiplied value : " + bigNum.multiply(BigInteger.valueOf(temp))); @@ -28,6 +34,10 @@ public static void main(String[] args) { System.out.println("GCD value : " + bigNum.gcd(BigInteger.valueOf(temp))); + System.out.println("ABS value : " + bigNum.abs(BigInteger.valueOf(temp))); + + System.out.println("Divided and Remainder value : " + bigNum.divideAndRemainder(BigInteger.valueOf(temp))); + } } diff --git a/Binary Serach in PHP/binarysearch.php b/Binary Serach in PHP/binarysearch.php new file mode 100644 index 00000000..9cd12412 --- /dev/null +++ b/Binary Serach in PHP/binarysearch.php @@ -0,0 +1,38 @@ +'; print_r( $sourceArr ); echo ''; +echo ( $position >= 0 ) ? 'Keyword ' . $keyword . ' is found at position: ' . $position : 'Your keyword is not found.'; + +?> \ No newline at end of file diff --git a/Binary-Search-c++/Binary Search.txt b/Binary-Search-c++/Binary Search.cpp similarity index 90% rename from Binary-Search-c++/Binary Search.txt rename to Binary-Search-c++/Binary Search.cpp index 80e20f2c..2b6fc8cc 100644 --- a/Binary-Search-c++/Binary Search.txt +++ b/Binary-Search-c++/Binary Search.cpp @@ -1,7 +1,6 @@ -#include #include using namespace std; - +//funtion for implementing binary search int binarySearch(int *input,int beg,int end,int number){ if(beg>end){ return -1; @@ -18,8 +17,10 @@ int binarySearch(int *input,int beg,int end,int number){ else{ return binarySearch(input,mid+1,end,number); } + + return -1; } - +//main funtion for calling and control int main(){ //Size of The Array int n,number; diff --git a/Binary-Search-c++/binary_search_using_recursion.cpp b/Binary-Search-c++/binary_search_using_recursion.cpp new file mode 100644 index 00000000..0ca448e0 --- /dev/null +++ b/Binary-Search-c++/binary_search_using_recursion.cpp @@ -0,0 +1,12 @@ +int binary_search(int sorted_list[], int low, int high, int element) +{ + if (high < low) + return -1; + int middle = low + (high - low)/2; + if (element < sorted_list[middle]) + return binary_search(sorted_list, low, middle-1, element); + else if (element > sorted_list[middle]) + return binary_search(sorted_list, middle+1, high, element); + else + return middle; +} diff --git a/Binary-Search-c++/binarysearch_basic.cpp b/Binary-Search-c++/binarysearch_basic.cpp new file mode 100644 index 00000000..0cfd6ab9 --- /dev/null +++ b/Binary-Search-c++/binarysearch_basic.cpp @@ -0,0 +1,44 @@ +#include + +using namespace std; + +int main() +{ + int n, i, arr[50], el, low, high, mid; + cout << "Enter size of list:"; + cin >> n; + cout << "Enter elements :"; + for (i=0; i> arr[i]; + } + cout << "Enter element to be searched:"; + cin >> el; + low = 0; + high = n-1; + mid = (low+high)/2; + while (low <= high) + { + if(arr[mid] < el) + { + low = mid + 1; + + } + else if(arr[mid] == el) + { + cout << el <<" found at location " << mid <<"\n"; + break; + } + else + { + high = mid - 1; + } + mid = (low + high)/2; + } + if(low > high) + { + cout << "Not found! " << el << " is not present in the list."; + } + + return 0; +} diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index a20f518b..d790e374 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,3 +1,257 @@ +Name: [Sarah](https://github.com/sarahxoxo)
+Place: Taiwan
+About: software engineering developer!
+Programming languages: JavaScript, Html, Css and plenty of other
+Email: sarah@gmail.com + + +Name: [Adish Rao]
+Place: INDIA
+About: Student and Developer in Python and Java
+Programming Language: Python,Java,C++
+Email: adish.rao98@gmail.com
+ +Name: [Harsh Ranpariya]
+Place: INDIA
+About: Student and Web Developer
+Programming Language: PHP,NodeJS
+Email: harshranpariya@gmail.com
+ +Name: [Harmeet Singh]
+Place: INDIA
+About: Student and Android Developer
+Programming Language: Java,Android
+Email: sharmeet167@gmail.com@gmail.com
+ +Name: [Youen FROGER](https://github.com/laenNoCode)
+Place: FRANCE
+About: software engineering student and developer! Likes async
+Programming languages: c++ c# Java Js Android PHP Ruby Python OCaml Html Css and plenty of other
+Email: Youen.froger2@gmail.com + +Name: [Vaibhav Raj](https://github.com/codebuster10x)
+Place: Kolkata, India
+About: Undergraduate in B.Tech, Information Technology.
+Programming Language: C/C++, HTML, CSS
+Email: vishuvaibhav10@gmail.com
+ +Name: [Maéva](https://github.com/maevabakhaw)
+Place: Paris, France
+About: Student
+Programming Language: HTML, CSS, Javascript
+Email: meh@gmail.com
+ +Name: [Bayli](https://github.com/baylisade)
+Place: Toronto, Ontario
+About: Student at UofT.
+Programming Language: HTML, CSS, Javascript, jQuery
+Email: bayli1@gmail.com
+ +Name: [Rohan Sharma](https://github.com/eXpErImEnTcoder)
+Place: India
+About: CS undergraduate. Experienced with web exploitation and cyber +security.
+Programming Language: C, C++, Python, JS.
+Email: rohansharma.rohan27@gmail.com
+ +Name: [Aaron Shivers](https://github.com/aaronshivers) +Place: Missouri +About: Hi, I'm just getting started. +Programming Language: JavaScript +Email: aaronshivers@gmail.com + +Name: [Lee T](https://github.com/leeturnbill) +Place: Tennessee +About: EMC Engineer +Programming Language: Python and C++ +Email: leeturnbill123@gmail.com + +Name: [Gabriel Cueto](https://github.com/TheMushrr00m)
+Place: Cancún, México. :glasses
+About: Software Developer, Speker.
+Programming Language: Elixir, Golang, Python, Ruby
+Email:admin@gcueto.com
+ +Name: [Dimali Dissanayake](https://github.com/dimalik98)
+Place: Sri Lanka
+About: UNdergraduate @ NSBM Green University.
+Programming Language: C,C#,Java,HTML,Python
+Email:dimalidissanayake.dd@gmail.com
+ +Name: [Anuj Kharbanda](https://github.com/Anuj2711) +Place: Muzaffarnagar,India. +About: Undergrad at BITS Pilani. +Programming Language: C , C++ +Email: anuj.kharbanda01@gmail.com + +Name: [Ahnaf Hadi Fathulloh](https://github.com/ahnafhf21)
+Place: Jakarta, Indonesia
+About: Student, Learner, Thinker.
+Programming Language: C++,Java,HTML,LUA,PHP,Pascal
+Email:ahnafhadi@gmail.com
+ +Name: [Kanishk Gupta](https://github.com/gkanishk)
+Place: INDIA
+About: Student and HackerEarth CA Likes learning.
+Programming Language: c++,Java,Android, JS, HTML, CSS
+Email: kanishkgupta1234@gmail.com
+ + +Name: [Prashant Shakya](https://github.com/shakyaprashant)
+Place:INDIA
+About: Grad Student at MNNIT ALLAHABAD
+Programming Language: C++,Java,Python
+Email: prashantshakya@outlook.com
+ + +Name: [wrecKING Tsukinoryoshu](https://github.com/tsukinoryoshu)
+Place:INDIA
+About: Student at BITS Pilani Hyderabad Campus
+Programming Language: Python
+Email: tsukinoroyoshu@gmail.com
+ +Name: [Arman Gupta](https://github.com/Arman1611)
+Place: INDIA
+About: Student and Android Developer.
+Programming Language: C,C++,Java,dart,python,Android, JS, HTML, CSS
+Email: armangupta0504@gmail.com
+ +Name: [Buddhima De Alwis](https://github.com/buddhima97)
+Place: Sri Lanka
+About: Undergraduate at NSBM Green University
+Programming Language: C,Java,HTML,CSS,Python
+Email: buddhimadealwis4@gmail.com
+ + + + +Name: [Aman Singh](https://github.com/AMANSINGH1998)
+Place: INDIA
+About: Student and Web developer! Likes AI.
+Programming Language: c++, JS, HTML, CSS
+Email: amansingh19981998@gmail.com
+ +Name: [Rahul Chauhan](https://github.com/rahulchauhan049) +Place: Greater Noida, India +About: web developer, speaker, alexa skills, aog +Programming Language: Javascript? +Email: rahul.chauhan049@gmail.com + + +Name: [Warushika Hansini](https://github.com/warushika)
+Place: SRILANKS
+About: Student and Web developer! Likes AI and UI& UX.
+Programming Language: JS, HTML, CSS, php, python
+Email: warushikamapalagama95@gmail.com
+ + +Name: [Adarsh Chaudhary](https://github.com/AdarshKC)
+Place: INDIA
+About: Studies CSE at IIT Patna
+Programming Language: C, C++, HTML, CSS, JAVASCRIPT
+Email: adarsh.cs17@iitp.ac.in
+ +Name: [Aminullah Taj Muhammad](https://github.com/AminullahTajMuhammad)
+Place: Pakistan
+About: Student and Software engineer!
+Programming Language: c, c++, java, HTML, CSS
+Email: aminullahtajmuhammad@gmail.com
+ + +Name: [Devinda Ravisara](https://github.com/devinda98)
+Place: Sri Lanka
+About: University Student
+Programming Language: c, java, HTML, Python
+Email: devindaravisara@gmail.com
+ +Name:[Mathieu Saubin](https://github.com/Doomfang3) +Place: FRANCE
+About: O'Clock student (Nova) learning web developpement.
+Programming Languages: HTML, CSS, JS, PHP, MySQL.
+Email: saubinm@free.fr
+ + +Name: [Fellipe Medeiros](https://github.com/FellipeMedeirosSilva)
+Place: Guarulhos, São Paulo
+About: Tech lover and Developer
+Programming Language: HTML, CSS, JS, NODE, C#
+Email: fellipe.medeiros1@gmail.com
+ +Name: [Ekansh Gupta](https://github.com/Ekansh-01)
+Place: Muzaffarnagar,INDIA
+About: B.Tech student at IIIT Allahabad
+Programming Languages: HTML,CSS,JAVA,C++,C
+Email: Gupta.ekansh.01@gmail.com
+ +Name: [Hritik Tayade](https://github.com/braceritchie)
+Place: Pune, India
+About: Diploma Student in Engineering and Technology
+Programming Languages: Java, Python
+Email: tayadehritik@gmail.com
+ +Name: [Jayesh Joshi](https://github.com/python-jjlearner)
+Place: India
+About: Student and Software engineer!
+Programming Language: c, c++, java, HTML, CSS, Python3 , PHP
+Email: masterjj1251@gmail.com
+ + +Name: [Jogi Miglani](https://github.com/jmig5776)
+Place: INDIA
+About: Mathematics and Computing student at IIT BHU and fitness freak.
+Programming Language: c++, python
+Email: jmig5776@gmail.com
+ + +Name: [Akshay Kumar](https://github.com/GHakshay)
+Place: Jaipur, Rajasthan, INDIA
+About: Student, Python Developer, Interested in AI.
+Programming Language: c, c++, python
+Email: akshay.at009@gmail.com
+ +Name: [Dileep Senevirathne](https://github.com/IshankaDSenevirathne)
+Place: SRI LANKA
+About: Physics Student
+Programming Language: java,python
+Email: ishankadsnevrathne@gmail.com
+ + +Name: [Yashraj Shrivastava](https://github.com/yashrj73)
+Place: Chennai, India
+About: Student Developer
+Programming Language: C++, JS, Java, Python
+Email: yashraj699@gmail.com
+ +Name: [Muhammad Alif A](https://github.com/saarques)
+Place: Keputih, Surabaya City, Indonesia
+About: Student College at PENS, Machine Learning and Data Science
+Programming Language: Python, Java
+Email: alifakbar111@gmail.com
+ +Name: [Mochammad Ilham Maulana](https://github.com/ilhamhzrd20)
+Place: Keputih, Surabaya City, Indonesia
+About: PENS Student, UI/UX Engineer
+Programming Language: HTML,CSS,PHP,Python
+Email: ilhambalcazar14@gmail.com
+ +Name: [Gajendra Saraswat](https://github.com/saarques)
+Place: Bikaner, Rajasthan, India
+About: Student, Aspiring Data Scientist
+Programming Language: Python, C, C++
+Email: saraswatgajendra97@gmail.com
+ +Name: [Arsalan Azmi](http://github.com/lethalazo) +Place: Aberystwyth +About: Ai student at Aberystwyth university +Programming Language: Java, Python, C, Cpp, Ruby, JavaScript, Haskell, +PHP +Email: arsalanazmi@hotmail.com + +Name: [Shivam](https://github.com/shivam)
+Place: INDIA
+About: Student and Web developer! Likes AI.
+Programming Language: c++, JS, HTML, CSS
+ Name: [Waqar Ahmed](https://github.com/waahm7)
Place: Pakistan
About: Computer sceince sutdent, intrested in logical & mathematical concepts.
@@ -6,7 +260,7 @@ Email: waahm7@gmail.com
Name: [pnjha](https://github.com/pnjha)
Place: India
-About: Computer science student, excited about AI and ML
+About: Computer science student, excited about AI and ML
Programming Language:C, C++, JAVA, R, Python, JS, HTML, CSS
Email: prakash.nath@students.iiit.ac.in
@@ -28,6 +282,12 @@ About: Computer Science student Programming Language: Python, C++, Angular 6, Typescript, C, PHP Email: alexbenchea99@yahoo.com +Name: [Björn Kristensson Alfsson](https://github.com/BKristenssonAlfsson)
+Place: Sweden +About: Computer programmer student +Programming language: Java EE, JPA, SpringBoot, Hibernate, Angular 6, Typescript +Email: bjorn.alfsson@gmail.com + Name: [jluo117](https://github.com/jluo117)
Place: Bay Area
About: Software engineer student!
@@ -38,7 +298,7 @@ Name: [Santino](https://github.com/santinohu)
Place: Netherlands
About: Software engineer student!
Programming Language: Python, PHP, Java, PL/SQL
-Email: santino.b@live.nl
Name: [Tharuja](https://github.com/Tharuja)
Place: Sri lanka
@@ -64,7 +324,6 @@ About: I love to code, solve programming problems. Currently working as devOps e Programming Language: C, python, java, ruby, scala, JS, bash
Email: mihaque313@gmail.com
- Name: [Miftahul J.](https://github.com/jiadibo)
Place: Indonesia
About: I'm moslem programmer
@@ -77,15 +336,26 @@ About: I'm pursuing 3rd year from MNNIT Allahbad
Programming Language: Java,C,C++
Email: utkarsh22garg@gmail.com
- Name: [Alex Wellnitz](https://github.com/n00d13)
Place: Ellern, Germany
About: Software Developer from Germany
Programming Language: C#, JS, Swift
+Name: [Collin Cates](https://github.com/collincates)
+Place: Los Angeles
+About: Software Developer
+Programming Language: Python
+Email: collin.cates@gmail.com
+ Name: [Eren Sertkaya](https://github.com/erensertkaya)
Place: Turkey
About: I'm web developer which develop passive-income projects
+ + +Name: [Ansh Kapoor](https://github.com/AnshKapoor)
+Place: Uttar Pradesh,India
+About: IT undergraduate from IP University,Delhi
+Programming Language:c,c++,Java,Javascript,Html,Css
Programming Language: Php,Javascript
Email: eren.sertkaya.es@gmail.com
@@ -106,13 +376,16 @@ About: I am 1st year Electrical Engineering student at IIT Mandi, Mandi.
Programming Languages: Python
Email: b18114@students.iitmandi.ac.in
- - Name: [Sajjal](https://github.com/sajjalt)
Place: New Delhi
About: I am presently studying computer science at Thapar Institue of Engineering and Technology and love coding.
Programming Language:C,C++,Python
+Name: [Keshav Kabra](https://github.com/ksvkabra/)
+Place: Jaipur
+About: I am presently studying computer engineering at JECRC.
+Programming Language:C, C++, php, js, python + Name: [Sajjal Tiwari](https://github.com/sajjalt)
Place: New Delhi
About: I am presently studying computer engineering at Thapar Institue of Engineering and Technology and loves coding.
@@ -128,7 +401,6 @@ Place: Mumbai
About: I am a computer engineer and loves coding.
Programming Language:C,C++,Python
- Name: [Harsh Bhut](https://github.com/harshbhut42)
Place: Gandhinagar
About: I am fast learner.
@@ -144,6 +416,11 @@ Place: Jaipur
About: I'm a computer science student and I love coding.
Programming Language : C,C++,Java,Python3
+Name: [Navdeep Singh](https://github.com/navdeep300)
+Place: Montreal, Canada
+About: I'm a Masters student in Quality System Engineering.
+Programming Language : C,C++,Html,PHP
+ Name: https://github.com/D3D0X
Place: Dronten
About: Dutch Linux engineer
@@ -155,14 +432,11 @@ Place: Jaipur, Rajasthan
About: I am 3rd yearComputer science student at poornima college of engineering, Jaipur. I am a front end developer.
Programming Languages: C, C++,python
- - Name: [Henry McCreery](github.com/hmccree) Place: Portland, Oregon, USA About: High school robotics team member project manager Programming language: Python - Name: Pritam Malik
Place: Shakarpur, New Delhi
About: Software Developer
@@ -343,6 +617,14 @@ About: I am currently studying computer science and technology in my B.Tech at I Programming Language: C++, C, python, HTML, css
Email: b17092@students.iitmandi.ac.in
+Name:[Sanduni Imalsha](https://github.com/sanduniisa)
+Place: Colombo, SriLanka
+About: I am an undergratuate in University of Colombo School of Computing in Information Systems.
+Programming Language: Python, C, HTML, CSS, PHP, JavaScript.
+Email: sanduniisa@gmail.com + + + Name: [Praveen Kumar Saini](https://github.com/praveen-me) Place: Dharamshala, India About: I am currently learning Full Stack Development and also a Google Uadicty India Scholar. @@ -383,7 +665,6 @@ About: I am a cience computer student at PUC Minas. Programming Language: Java, JavaScript, PHP, C, Python Email: viniciusmsdsantos@gmail.com - Name: [Brian Phair](http://brianphair.com) About: I'm have a B.S. degree in Chemistry and am about to finish up a B.S. degree in Computer Science. Programming Language: C, C++, Python @@ -489,26 +770,22 @@ About: I am a sophomore at IIT Mandi
Programming Languages: C, C++, JavaScript
Email: vsvipul555@gmail.com - Name: [Samyak](https://github.com/samyak-sopho) Place: Allahabad About: Will do anything for free shirt Programming Language: C++, JS, Java - Name: [Marlene Oliveira](https://github.com/m-oliv) Place: Lisbon, Portugal About: Software Engineer Programming Language: Java, C, C#, Python, JavaScript, HTML, CSS - Name: [Trevin Edinger](https://github.com/ArkTrevelyan) Place: Elkins, WV, USA About: High School Graduate. Self teaching to be a programmer. Programming Languages: Java, C. Email: Yezhekel@ProtonMail.ch - Name: [Tsaruk Alex](https://github.com/WildTiger404)
Place: Minsk, Belarus
About: I am a 3rd year stundent. I like traveling and events like this one
@@ -521,7 +798,6 @@ About: I am a 3rd Year Computer Science student at JSSATE Noida
Programming Languages: C, Java
Email: priyankarajput3010@gmail.com - Name: [Darshan D V](https://github.com/darshandv)
Place: Mangalore, Karnataka ,India
About: I am a Computer Science student at NITK Surathkal
@@ -534,7 +810,6 @@ About: Btech student from JIIT
Programming Languages: C,C++,python3
email: ranjan.kushwaha456@gmail.com
- Name: [Kartik Singh](https://github.com/Kartik212112)
Place: Patna,India
About: Btech student from IITP
@@ -565,6 +840,11 @@ About: Computer Science student at Federal University of Campina Grande (UFCG).< Programming Languages: C/C++, Java, Python, PHP, Haskell
Email: lucasmed812@gmail.com
+Name: [Avinash Raghuthu](https://github.com/avinashraghuthu)
+Place: India
+About: Software Engineer
+Programming Languages: Python, Java, C++
+ Name: [Vincent]()l
Place: USA
About: I am a person who enjoys looking at code, but isn't very good writing it. Looking for a good time.
@@ -621,13 +901,11 @@ Place: Manipal, Karnataka
About: Second year IT undergrad.
Programming Languages: C++, Python
- Name: [Bodin Chinthanet](https://github.com/gotzillaz)
Place: Nara, Japan
About: Ordinary student Programming Languages: C++, Python, Java, C#, JavaScript, R
- Name: [Ahmad Javed](https://github.com/ahmadjaved97)
Place: New Delhi, Delhi
About: Third year Mathematics and Computing Undergrad at DTU.
@@ -651,7 +929,7 @@ Programming Languages: Java, JavaScript, PHP, CSS
Name: [Ronit Maitra](https://github.com/zon2) Place: Jalpaiguri , West Bengal. About: 3rd year Computer science and engineering. -Programming Languages: C,Java , Ruby ,C++, Python +Programming Languages: C,Java , Ruby ,C++, Python Name: [Muhammad Ridwan Fathin](https://github.com/ridwanfathin)
Place: Bandung, Indonesia
@@ -663,6 +941,11 @@ Place: Delhi, India
About: I am a Second year IT undergrad.
Programming Languages: C++, Python, Java
+Name: [Peerarust Siriamphan](https://github.com/Gnoyoyo)
+Place: Bangkok, Thailand
+About: Junior Software Engineer
+Programming Languages: TypeScript, C++, Python
+ Name: [Andrew Miracle](https://github.com/koolamusic) Place: Lagos, Nigeria About: Developer Intern at Learnfactory @@ -690,21 +973,18 @@ About: Computer Science BTech student from GGSIPU. I'm currently interested in W Programming Languages: C, C++, Python, JavaScript
Email: agoel00@gmail.com
- Name: [Kamakshi Behl](creative-computing-society.github.io)
Place: Amritsar, India
About: Computer engineering from Thapar University, Patiala
Programming Languages:C, C++
Email: kamakshi.behl22@gmail.com
- Name: [Sean D'Souza](https://github.com/seendsouza)
Place: Ottawa, Canada
About: High school student currently interested in big data and analytics
Programming Language: Python, VB, AWK
Email: sdammobubbles@gmail.com
- Name: [Stephen Sladek](https://github.com/stanecobalt)
Place: Cape Girardeau, MO
About: Information Systems undergrad at SEMO, works as a web dev, interested in VR
@@ -716,7 +996,6 @@ About: CS Undergrad Student at University of Indonesia
Programming Languages: C++, Python, R
Email: krisnaihsani@gmail.com
- Name: [Paul Williams](https://github.com/WilliamsPaulM) Place: USA About: Bash Enthusiast @@ -727,65 +1006,56 @@ Place: London, UK
About: Proud owner of one dog and two cats
Programming Languages: JavaScript all the way!
- Name: [Dhruv Patel](https://github.com/dhruv007patel)
Place: Gujarat
About: Currently pursuing B.tech from Amrita University.
Programming Languages: Java, Python, C++,C#
- Name: [Jeremy Chen](https://github.com/jeremy850407)
Place: Taipei, Taiwan
About: Graduate Student
Programming Languages: Java, Python, C, C++, Javascript
- Name: [Michele Riva](https://github.com/micheleriva)
Place: Milan, Italy
About: Machine Learning, Functional Programming, Web Development
-Programming Languages: JavaScript, C++, Haskell, Scala, Python, Ruby +Programming Languages: JavaScript, C++, Haskell, Scala, Python, Ruby
+Name: [Elaine Akemi](https://github.com/elaineakemi)
+Place: Dublin, Ireland
+About: Software Developer
+Programming Languages: C#, ASP.NET, JavaScript
Name: [Andrea](https://github.com/kaywinnet)
Place: Madrid, Spain
About: Graduate Student
Programming Languages: Python, C++, R - - Name: [Anushka Bhandari](https://github.com/anushkab)
Place: Delhi ,India
About: Undergraduate @IIITD
Programming Languages: Java, Python - - Name: [Mridul Aggarwal](https://github.com/Mridul97)
Place: New Delhi, India
About: Machine Learning Enthusiast
Programming Languages: JavaScript, C++, Python, Java - Name: [Rehan](https://github.com/Rehan1995)
Place: Kadawatha , Srilanka
About: undergraduate student
Programming Languages: Java, Python, C#, Javascript
- Name: [Shreyansh Kulshreshtha](https://github.com/shreyanshkuls)
Place: Mandi, Himachal Pradesh, India
About: Undergraduate student, Music enthusiast, like programming
Programming Languages: C, C++
- Name: [Tafique](https://github.com/tafique)
Place: Bhubanewswar
-About: I am presently studying Instrumentation and electronics at College of Engineering and Technology and love coding.
+About: I am presently studying Instrumentation and electronics at College of Engineering and Technology and love coding.
Programming Language:C,C++,Python
- - - Name: [Daniel Dusek](https://github.com/dusekdan) Place: Brno, Czech Republic || Heraklion, Krete About: No one of consequence. @@ -796,83 +1066,79 @@ Place: Kochi, Kerala, India
About: B.Tech Student
Programming Languages: C, C++
- Name: [Ahmet Burak Baraklı](http://github.com/ahmetburakbarakli)
Place: Ankara, Turkey
About: CS Undergrad Student at Middle East Technical University
Programming Languages: Java, C++, Python
- - Name: [Mayank Abhishek](https://github.com/abhishekmayank) Place: Bangalore, India About: Web Developer, Data Enthusiast Programming Language: Python, Javascript, PHP, R Email: mail.mabhishek@gmail.com - Name: [Angelo Teoxon](http://github.com/ateoxon)
Place: Houston, TX
About: Undergrad CS major, enjoy web dev, data mining, and databases!!
Programming Languages: Python, Java, Javascript, PHP
- Name: [bjellesma](https://github.com/bjellesma) Place: Massachusetts About: Programmer, Captain Crunch devourer Programming Language: Python, JavaScript Email: william.jellesma@gmail.com - Name: [yugesh baral](http://github.com/yogibrl)
Place: Bhaktapur, Nepal
About: To be Computer Engineer
Programming Languages: C, C++
- - Name: [Thaynnara Gonçalves](https://github.com/thaynnara007)
Place: Campina Grande, Paraiba, Brasil
About: I am a 3rd Year Computer Science student at UFCG (Universidade Federal de Campina Grande)
Programming Languages: Python, Java, JavaScript, Prolog
- Name: [Canoi Gomes](https://github.com/canoi12)
Place: Natal, Brazil
About: IT Student
Programming Languages: C, C++, Lua, Python, JavaScript, C#, GML
Email: canoiaguiar@gmail.com
- Name: [Gabriel Nobrega](https://github.com/gabrielomn)
Place: Paraiba, Brazil
About: Undergraduate student at UFCG
Programming Languages: C, Python, Java, JavaScript
- Name: [Leandro Ferreira](https://github.com/leofls)
Place: Maceió, Alagoas Pradesh, Brazil
About: robotics teacher, programming student
Programming Languages: PHP, C++, Java, Python
- Name: [Rob Anderson](http://github.com/riznob)
Place: Beaverton, Oregon, USA
About: Father, althete, snowboarder, surfer, drummer
Programming Languages: Java, groovy, javascript, bash, python, php
- Name: [abbusofyan](http://github.com/abbusofyan)
Place: Jakarta, Indonesia
About: Student at Gunadarma University, have a passion in programming
Programming Languages: php, java, javascript
- Name: [Felipe](https://github.com/ja1felipe)
Place: Brazil
About: I am studying computer science.
Programming Language:Python, java
+Name: [Slothy](https://github.com/gyasikn)
+Place: Florida, USA
+About: Software Developer
+Programming Language: JavaScript, Ruby, HTML & CSS
+ + +Name: [llshwetall](https://github.com/llshwetall)
+Place: India
+About: 2nd year B.tech student at IIITH.
+Programming Language:Python, C++, C, Bash, Reactjs, golang
Name: [Hugo](https://github.com/katyushi)
@@ -880,8 +1146,6 @@ Place: São Paulo, Brazil
About: I am studying System development.
Programming Language:PHP, Java, Pascal
- - Name: [Jiradeto](https://github.com/jiradeto)
Place: Bolzano, Italy
About: master student who enjoy coding.
@@ -899,31 +1163,40 @@ About: I am a Computer Science and Engineering student.
Programming Language: Java, Python, C, C++, JavaScript
Email: syedsalifmoin@gmail.com - - Name: [Priyadarshan Singh](https://github.com/PDROJACK) Place: Delhi About: CS undergraduate Programming Language: Python,Javascript,C,C++ Email: singhpd75@gmail.com + + Name: [emekoi](https://github.com/emekoi) Place: antarctica About: i like programming but i can't finish anything Programming Language: c, zig, lua, nim, rust (kinda), java (kinda) - - Name: [Pijus](https://github.com/pijusrancevas) Place: Horsens, Denmark About: Software Engineer student Programming Language: Python, Javascript, JAVA (soon), C# +Name: [porpeeranut](https://github.com/porpeeranut) +Place: Earth Planet +About: Dev +Programming Language: C + Name: [Anish Kumar Singh](https://github.com/anishkumarsingh93) Place: Gurugram, India About: Go Developer and Data Scientist looking out for real world challanges. Programming Language: Go,Python + + +Name: [Anish Kumar Singh](https://github.com/anishkumarsingh93)
+Place: Gurugram, India
+About: Go Developer and Data Scientist looking out for real world challanges.
+Programming Language: Go,Python
Email: anishkumarsingh93@gmail.com @@ -933,6 +1206,7 @@ About: CS Undergraduate, Python Developer and ML Enthusiast Programming Language: Python3, Js, C++ Email: dishantrathi97@gmail.com + Name: [Luke594](https://github.com/Luke594)
Place: Italy
About: Programmer, developer, thinker
@@ -944,7 +1218,6 @@ About: A Data Enthusiast with 8+ Years of Experience in MS Office & AutoHotkey Programming Language: VBA, AHK, SQL(Basics), R(Basics) Email: shyam.dragon89@gmail.com - Name: [Payal Pandya](https://github.com/payPan22) Place: Pune, Maharashtra, In About: Software Developer @@ -963,26 +1236,35 @@ About: Student at BIT Mesra Programming Language: C++, Java, Python Email: ankurdubey521@protonmail.com - Name: [Raul Almeida](https://github.com/haltsimog) Place: Curitiba, Brazil About: CS student at Federal University of Paraná Programming Language: C, Python Email: haltsimog@gmail.com +Name: [Christophoros](https://github.com/christophorosdk) +Place: Copenhagen, Denmark +About: Student +Programming Language: Python +Email: christoffer@chrisharrits.com + Name: [Jewell Scott](https://github.com/jewellscott) Place: city you belong to About: Developer and Creative Technologist Programming Language: JavaScript Email: jewelljrscott@gmail.com +Name: [Mathew Carroll](https://github.com/raedryn) +Place: Massachusetts, United States +About: Amateur Developer +Programming Language: HTML, Javascript +Email: raedryn@gmail.com Name: [0xjhow](https://github.com/0xjhow) Place: Recife About: InfoSec professional Programming Language: bash script, Python and C - Name: [Leonardo Sena](https://github.com/leosena21)
Place: Salvador, Brazil
About: Computer Engineer
@@ -990,32 +1272,62 @@ Programming Language: C#, Python
Email: leeosena21@gmail.com
+Name: [Zakariya](https://github.com/f-zee)
+Place: GitHub :D
+About: Junior Android Developer
+Programming Language: Java, Python
+ +Name: [Apostolos Papadopoulos](https://github.com/ApostPap)
+Place: Thessaloniki, Greece
+About: Third year in college styding Computer Science.
+Programming Language: Java, C
+Email: apostolos114@gmail.com
+ +Name: [Samir](https://github.com/Qhsami) +Place: TX, USA +About: .NET Developer +Programming Language: C#,JS,PHP + + +Name: [Sandy Edwards](https://github.com/slowbeam) +Place: Hoboken, NJ USA +About: Electronic music producer and artist turned web developer. +Programming Language: Javascript, Ruby +Email: sedwardscode@gmail.com + +Name: [Prabhát Kumar](https://github.com/bart-bk)
+Place: Salvador, Brazil
+About: Software Engineer
+Programming Language: C#, Python, C, JavaScript, PHP, Java
+Email: bartkoliveira@gmail.com
+ +Name: [Keshav Bhatia](https://github.com/keshav095)
+Place: delhi,india
+About: Computer Engineer
+Programming Language: C, Python,html,css
+Email: ishaun1312@gmail.com
+ Name: [Austin ZUniga](https://github.com/AustinZuniga) Place: Manila,Philippines About: Backend Developer Programming Language: Python, C, C++, php Email: earlaustin.zuniga@bicol-u.edu.ph - Name: [M4l2tIlV](https://github.com/M4l2tIlV)
Place: Around the World
About: Developer
Programming Language: JAVA, PYTHON, JS, PHP
- Name: [LCaleb Conrad](https://github.com/ccconrad)
Place: Ohio, United States. -About: Programmer and avid drinker. +About: Programmer and avid drinker. Programming Language: C#, C++ - Name:[Himanshu Thanna](https://github.com/himanshuthanna) Place:Delhi,India About:TCS Employee Programming language:Java,C - - Name: [sakshi pareek](https://github.com/sakshipareek)
Place: Rajasthan, India
About: student
@@ -1067,15 +1379,440 @@ About: Computer Engineering Student
Programming Language: C, Javascript, Java
Email: paulobruny@gmail.com
- Name: [Arvind Rachuri](https://github.com/arealdeadone)
Place: Gwalior, India
About: IT student at ABV - Indian Institute of Information Technology and Management, Gwalior
Programming Languages: C++, C, JAVA, Ruby, Python, JavaScript, Golang
Email: ari0997@gmail.com
+ +Name: [Furkan Göksel](https://github.com/FireHunter27)
+Place: Ankara, Turkey
+About: Computer Engineering Student
+Programming Language: python, java, c, c++
+Email: furkan.goksel27@gmail.com
+ +Name: [Alvin Tandiardi](https://github.com/alvintan05)
+Place: DKI Jakarta, Indonesia
+About: Information Technology Student
+Programming Language: C++, Java
+Email: alvintandiardi@gmail.com
+ + Name: [Furkan Göksel](https://github.com/FireHunter27) -Place: Ankara, Turkey +Place: Ankara, Turkey About: Computer Engineering Student Programming Language: python, java, c, c++ -Email: furkan.goksel27@gmail.com \ No newline at end of file +Email: furkan.goksel27@gmail.com + +Name: [Paul Flanagan](https://github.com/paultflanagan)
+Place: New Jersey, United States
+About: Computer Science Student and Intern
+Programming Languages: Java, Python, VBScript
+Email: paultflanagan@gmail.com
+ + +Name: [Zachary Dixon](https://github.com/zachdixon) +Place: Dallas, TX +About: Lead Front End Developer, gamer, woodworker +Programming Language: JavaScript + + +Name: [Deumus74](https://github.com/Deumus74) +Place: Berlin +About: git newbee +Programming Language: Python, Purebasic + + +Name: [Eric Chen](https://github.com/LacticAcidCYC) +Place: Los Angeles, US +About: I am a graduate student major in Computer Science in University of Southern California +Programming Language: C++, Java, JavaScript, PHP, Python +Email: rsjcyc@gmail.com + +Name: [Lucas Marinzeck](https://github.com/Lucas-Marinzeck)
+Place: Ribeirão Preto, Brazil
+About: CS Student
+Programming Language: C#, C
+Email: lucasmarinzeck@gmail.com
+ +Name: [Ricardo Kojo](https://github.com/ricardokojo)
+Place: São Paulo, Brazil
+About: CS Student at Universidade de São Paulo
+Programming Languages: C, Java, Javascript, Ruby, Python
+Email: ricardokojo@usp.br + + +Name: [Ankush Mehta](https://github.com/Ankush3103) +Place: Aurangabad, Delhi +About: I am an ambitious coder and avid reader. +Programming Language: HTML, CSS, RUBY, PYTHON + + +Name: [Dayitva Goel](https://github.com/Dayitva) +Place: Karawang, Indonesia +About: Senior School Graduate from DPS Indonesia. Love tech and business. +Programming Language: Java +Email: dayitvagoel@gmail.com + +Name: Minu Kumari(https://github.com/minukumari)
+Place: New Delhi
+About: Student
+Programming Languages: C, C++,python,HTML,CSS,JAVASCRIPT,Django
+ +Name: Prasoon Pandey(https://github.com/GammaBurst101) +Place: Allahabad, India +About: Computer Science Student with a youtube channel : Gamma Guy +Programming Language: HTML, CSS, JS, Java +Email: prasoonpandey24@yahoo.com + +Name: [Andrea Rucco](https://github.com/MaxiStarling56) +Place: Lecce, Italy +About: Computer Fanatic/Lover/Student +Programming Language: C, C++, HTML, CSS. +Email: maxistaling@gmail.com + + +Name: Aviral Chauhan(https://github.com/Aviralchauhan7) +Place: Patiala, India +About: Electronics & Communication Engineering student from Thapar Institute of Engineering & Technology + + +Name: [Victor Domiciano Mendonça](https://github.com/victordomiciano) +Place: São Paulo, Brazil +About: Computer Science Student at IME-USP +Programming Language: C, Java, Python, GDScript +Email: victor.dm3@gmail.com + +Name: [Patrick Bateman](https://github.com/pbateman828)
+Place: South Carolina, USA
+About: Junior Developer
+Programming Language: Rust
+Email: pbateman828@gmail.com
+ +Name: [Prashant Dixit](https://github.com/prashant564)
+Place: INDIA
+About: Student and Machine Learning enthusiast! Likes Python.
+Programming Language: c++, Python, Java
+Email: prashantdixit600@gmail.com
+ + +Name: Yobani Mendoza(https://github.com/Yobani1987)
+Place: Oklahoma City, OK
+About: Front End Dev. Student at Francis Tuttle Technology Center
+Programming Language: HTML, CSS, JS, PHP
+Email: lzme4@yahoo.com
+ + +Name: [Dmitry](https://github.com/N0menIllisLegio)
+Place: Belarus
+About: Student
+Programming Language: c#, c++, java, HTML, CSS
+ + +Name: [William Zhou](https://github.com/wzhouwzhou)
+Place: White Plains, New York, USA
+About: Business Administration and Management-Finance Major in Questrom School of Business at Boston University | Questrom Student Government Senator 2018-Present; Developer, Systems Administrator, Designer, Chatbot Creator, and More. I also study the violin and piano.
+Programming Language: Proficient: Node JS, Coffeescript; Front-End Javascript, HTML, CSS, Java, Python, C++
+Email: wzhouwzhou@gmail.com
+ +Name: [StrongWong](https://github.com/strongwong)
+Place: China
+About: Embedded Software Enginner
+Programming Language: C/C++, Python
+Email: strongwong003@gmail.com
+ +Name: Nalin Luthra +Place: New Delhi, Delhi, India +About: Student, Robotic Researcher +Programming Language: Python, C, C++, Java +Email: nalin.luthra@gmail.com + +Name: [BHONESH CHAWLA](https://github.com/bhonesh1998)
+Place: JAIPUR,RAJASTHAN,INDIA
+About: android developer and competitive coder
+Programming Language: c,cpp,java
+Email: rajachawla778@gmail.com
+ + +Name: [Ilham Firdausi Putra](https://github.com/Ilhamfp31) +Place: Indonesia +About: Student and Software engineer! +Programming Language: C++, Python, Java + +Name: [Erick Surya Dinata](https://github.com/proesd) +Place: Indonesia +About: I'm just a person who curious with technology and science +Programming Language: most used: PHP, HTML, CSS, Javascrtipt other: SHELL, Python, Java, C++, Solidity + + +Name: [Waramun Achametra](https://github.com/booms2p)
+Place: Bangkok, Thailand
+About: Developer
+Programming Language: Javascript, TypeScript, Nodejs
+Email: booms_2p@hotmail.com
+ +Name: [Anubhab Sen](https://github.com/anubhabsen)
+Place: INDIA
+About: Students dabbling in computer vision
+Programming Language: Python, C++, MATLAB
+Email: anubhab.sen@gmail.com
+ +Name: [Vaibhav Tandon](https://github.com/vaibhav111tandon)
+Place: Greater Noida,India
+About: Front End Developer and IT Engineer
+Programming Languages: JAVA,C,PYTHON,JAVASCRIPT +Email: vaibhav.tandongcet@gmail.com
+ +Name: [Asim Subedi](https://github.com/asimsubedi)
+Place: Los Angeles
+About: Front End Developer
+Programming Language: C, Python, javascript +Email: asim.232@gmail.com + + +Name: [Vaibhav Gulati](https://github.com/gulvaibhav20)
+Place: INDIA
+About: Student, willing to learn something new
+Programming Language: C++,Python
+Email: gulvaibhav20@gmail.com
+ +Name: [Hearot](https://github.com/hearot)
+Place: Florence, Italy
+About: Software Developer
+Programming Languages: Python, Go, PHP, C++
+Email: gabriel@hearot.it
+ + +Name:[Sudhanshu Jaisani](https://github.com/sudhanshujaisani38)
+Place:Indore,India
+About:Oracle Certified Developer. +Programming Languages: Java*,C,Python,Android.
+Email:sudhanshujaisani38@gmail.com
+ +Name: [Tom](https://github.com/hypery11)
+Place: Taichung
+About: Student @Tunghai University
+Programming Language: PHP,PYTHON,JS
+Email: hypery11@gmail.com
+ +Name: [saurav kumar](https://github.com/hacksaurav)
+place: Chandigarh +About: I am a robotics developer and electronics engineer
+Programming Language: c,HTML,JAVASCRIPT +Email: sauravgalaxy64@gmail.com + +Name: [Owura Asare](https://github.com/owura82)
+Place: NYC, New York
+About: Student
+Programming Languages: Java, Python, C
+Email: oka217@nyu.edu
+ +Name: [Helen França Medeiros](https://github.com/helenfranca)
+Place: Espírito Santo, Brazil
+About: Bachelor's Student in Information Systems and I like travel.
+Programming Language: C,Java, HTML, CSS, Python
+Email: helenfranca93@gmail.com
+ +Name: [Karm0s](https://github.com/Karm0s)
+Place: Bejaia, Algeria
+About: Python developer.
+Programming Languages: Python, C++, C#
+Email: bouchenna.yanis@protonmail.com
+ +Name: [Zayam Tariq](https://github.com/234082) +Place: USA +About: Computer Science Student +Programming Languages: Swift, C++ +Email: zayamtariq@yahoo.com + +Name: [Fahri Güreşçi](https://github.com/fahri314) +Place: Turkey, Tekirdağ +About: Computer Enginner +Programming Language: Python, C++, C, Javascript +Email: fahri314@gmail.com + + + +Name: [Bhushan Khanale](https://github.com/bkhanale)
+Place: Pune, India
+About: Competitive Programmer
+Programming Languages: C, C++, JAVA, Python +Email: bkhanale@gmail.com + + +Name: [Chonnawee Chatcherthaicharoen](https://github.com/chonnawee4)
+Place: Bangkok, Thailand
+About: iOS Developer
+Programming Languages: Swift, Javascript
+Email: chonnawee.ch@gmail.com
+ + +Name: [Abhisek Chaudhuri](https://github.com/abhisekssp4025)
+Place: West Bengal, India
+About: Front End Developer +Programming Languages: C++, Python, HTML, CSS, JavaScript +Email: abhisekssp4025@gmail.com + +Name: [Daniel Hernqvist](https://github.com/hernqvistdaniel)
+Place: Stockholm
+About: Studying Full-Stack development at Chas Academy in Stockholm.
+Programming Language: HTML, CSS, JavaScript
+Email: danielsan_86@hotmail.com
+ +Name: [Thái Huy Nhật Quang](https://github.com/thaihuynhatquang)
+Place: Hà Nội, Việt Nam
+About: Developer
+Programming Languages: Javascript, C/C++, Python +Email: thaihuynhatquang@gmail.com + +Name: [Carlos Carvalho](https://github.com/chcdc)
+Place: Brazil
+About: SysAdmin and Infrastructure Analyst
+Programming Languages: PYTHON,SEHLL SCRIPT +Email: chenriquecdc@gmail.com + + +Name: [Djamel Eddine YAGOUB](https://github.com/DjamelEd)
+Place: Algeria
+About: IT engineer
+Programming Language: Python,Java,Android, JS, HTML, CSS
+Email: djamel.ed.y@gmail.com
+ +Name: [Lokesh Todwal](https://github.com/lokesh005)
+Place: Bengaluru, Karnataka
+About: Data Scientist
+Programming Languages: PYTHON +Email: lokeshtodwal005@gmail.com + +Name: [Yatharth Vardan}(https://github.com/YATHARTHVARDAN)
+Place: Delhi,India
+About: Student in DTU
+Programming Languages:C++ +Email: yatharthvardan@gmail.com + + + +Name: [Shruti Garg}(https://github.com/gargshruti30)
+Place: Delhi,India
+About: Student in NSIT
+Programming Languages: C/C++ +Email: gargshruti30@gmail.com + +Name: [Brendan Surtees](https://github.com/brendan-js) +Place: Brisbane, Australia +About: I'm a 2nd year Computer Science student, studying at Queensland University of Technology +Programming Language: Python, Java, C# +Email: brendan2511@gmail.com + +Name: [HARSH GUPTA](Github Link) +Place: ASSAM,GUWAHATI +About: BTECH CSE AT IITG +Programming Language: C++;PYTHON +Email: hagu0987@gmail.com + +Name: [Sakuna Madushanka](https://github.com/Sakuwz)
+Place: Nuwara Eliya,Sri Lanka
+About: Reading for Software Engineering BSc(Hons) - University of Kelaniya,Sri Lanka
+Programming Languages:C++,java,C,C#
+Email: sakuwwz@gmail.com
+ + +Name: [Aditya Menon](https://github.com/m-aditya)
+Place: Kochi, Kerala, India
+About: CSE Student
+Programming Language: Python, C, javascript
+Email:adityamenon1996@gmail.com
+ + +Name: [Jaynil Shah](https://github.com/jaynilshah)
+Place: Vadodara ,Gujarat,India
+About: Gamer, Developer
+Programming Languages:Java +Email: jaynil.shah84@gmail.com + +Name: [ADITI AGGARWAL](https://github.com/aditi2205) +Place: DELHI +About: Software Developer +Programming Language: c, c++, java, python +Email:aditi22aggarwal@gmail.com + +Name : [Achillix](https://github.com/achillix)
+Place : Jakarta , Indonesia
+About : Future Programmer | Newbs | 18" | IT engineer colleger +Programming Languages : C++ , html +Email : yagami.chira@gmail.com + +Name : [Sachin Pawar] (https://github.com/pwrsachin)
+Place : IIT Kharagpur, India
+About :I am second year undergraduate student, studying in IIT Kharagpur
+Programming Languages :C,C++,Python +Email : pwrsachin666@gmail.com + +Name : [Rohit Motwani](https://github.com/rohittm)
+Place : India
+About : Programmer, WordPress and WooCommerce Ninja +Programming Languages : JavaScript, PHP + +Name : [Monika Kumari] (https://github.com/MONIKA2013IGDTU)
+Place : New Delhi , India
+About : Btech CSE | IGDTUW | +Programming Languages : C++ , html +Email : monika7537kr@gmail.com + + +Name : [Tran Tat Huy](https://github.com/HrTran)
+Place : Hanoi , Vietnam
+About : Big Data Engineer +Programming Languages : scala, java, python +Email : huyict58@gmail.com + +name: [Nathan Melaku](https://github.com/Nathan-Melaku)
+Place: Bahir Dar, Ethiopia
+about: Student at BDU
+Programming Languages:C,C++,Python,Ruby
+Email: nathanmelkau@gmail.com
+ + +Name: [Jonathan Chavez](https://github.com/JonathanChavezTamales) +Place: Guadalajara +About: CS Student +Programming Language: Python +Email: jonachuy@hotmail.com + +Name: [Andrea Francesco Iuorio](https://github.com/afiuorio) +Place: Italy +About: Junior Software Engineer +Programming Language: C, C++, Java, C#, Python, Scala +Email: andreafrancesco.iuorio@gmail.com + +Name : Rahul Mishra +Place : Noida(India) +About : B.Tech(CSE) student +Programming Language : C +Email : misrarahul1100@gmail.com + +Name : [Trishla Verma](https://github.com/trishla08)
+Place : New Delhi , India
+About : Coding Enthusiast | Computer Engineering Student +Programming Languages : C, C++, Java, Javascript +Email : trishla.verma@gmail.com + + +Name : [Yusuf Adefolahan](https://github.com/sanxy)
+Place : Abuja , Nigeria
+About : Coding | Android Developer +Programming Languages : Java +Email : yusufadefolahan@gmail.com + +Name: [Martynas Jasin](https://github.com/Miautawn) +Place: Lithuania +About: Student +Programming Language: C++, Java, C#, JavaScript; +Email: miautawn@gmail.com + +Name: Saloni Gupta (https://github.com/upsidedownpancake) +Place: India +About: Student +Programming Language: C, C++, Java, Python +Email: saloni.gupta63@gmail.com \ No newline at end of file diff --git a/Ceaser-Cipher/ceaser-cipher-decryption.c b/Ceaser-Cipher/ceaser-cipher-decryption.c new file mode 100644 index 00000000..a9ef93d5 --- /dev/null +++ b/Ceaser-Cipher/ceaser-cipher-decryption.c @@ -0,0 +1,39 @@ +#include + +int main() +{ + char message[100], ch; + int i, key; + + printf("Enter a message to decrypt: "); + gets(message); + printf("Enter key: "); + scanf("%d", &key); + + for(i = 0; message[i] != '\0'; ++i){ + ch = message[i]; + + if(ch >= 'a' && ch <= 'z'){ + ch = ch - key; + + if(ch < 'a'){ + ch = ch + 'z' - 'a' + 1; + } + + message[i] = ch; + } + else if(ch >= 'A' && ch <= 'Z'){ + ch = ch - key; + + if(ch < 'A'){ + ch = ch + 'Z' - 'A' + 1; + } + + message[i] = ch; + } + } + + printf("Decrypted message: %s", message); + + return 0; +} \ No newline at end of file diff --git a/Ceaser-Cipher/ceaser-cipher-encryption.c b/Ceaser-Cipher/ceaser-cipher-encryption.c new file mode 100644 index 00000000..0b6b1a8a --- /dev/null +++ b/Ceaser-Cipher/ceaser-cipher-encryption.c @@ -0,0 +1,39 @@ +#include + +int main() +{ + char message[100], ch; + int i, key; + + printf("Enter a message to encrypt: "); + gets(message); + printf("Enter key: "); + scanf("%d", &key); + + for(i = 0; message[i] != '\0'; ++i){ + ch = message[i]; + + if(ch >= 'a' && ch <= 'z'){ + ch = ch + key; + + if(ch > 'z'){ + ch = ch - 'z' + 'a' - 1; + } + + message[i] = ch; + } + else if(ch >= 'A' && ch <= 'Z'){ + ch = ch + key; + + if(ch > 'Z'){ + ch = ch - 'Z' + 'A' - 1; + } + + message[i] = ch; + } + } + + printf("Encrypted message: %s", message); + + return 0; +} \ No newline at end of file diff --git a/CheckPalindrome.java b/CheckPalindrome.java new file mode 100644 index 00000000..687a2975 --- /dev/null +++ b/CheckPalindrome.java @@ -0,0 +1,26 @@ +import java.util.Scanner; +class CheckPalindrome { + public static void main (String args[]) { + System.out.print ("Enter a number: "); + int a = new Scanner(System.in).nextInt(); + + if (checkPalindrome(a)) + System.out.println("It is a palindrome!"); + else + System.out.println("It is not a palindrome."); + } + + private static boolean checkPalindrome(int n) { + String r = ""; + String num = Integer.toString(n); + + for (int i = num.length() - 1; i >= 0; i--) { + r += num.charAt(i); + } + + if (r.equals(num)) + return true; + else + return false; + } +} diff --git a/Circular linkedlist/DSN_CircularLinkedLIst.c b/Circular linkedlist/DSN_CircularLinkedLIst.c index 611edca5..e83bb963 100644 --- a/Circular linkedlist/DSN_CircularLinkedLIst.c +++ b/Circular linkedlist/DSN_CircularLinkedLIst.c @@ -1,16 +1,17 @@ #include #include -struct circularNode{ +struct circularNode +{ int data; - struct circularNode* next; + struct circularNode* link; }; struct circularNode* createnode(int a){ struct circularNode* newnode = (struct circularNode*)malloc(sizeof(struct circularNode)); newnode->data=a; - newnode->next=NULL; + newnode->link=NULL; return newnode; }; @@ -22,7 +23,7 @@ void show(struct circularNode* head){ } do{ printf("%d ",temp->data); - temp=temp->next; + temp=temp->link; }while(temp!=head); } @@ -33,10 +34,10 @@ void insert_front(struct circularNode** head,int a){ if(*head==NULL){ *head=newnode; - newnode->next=NULL; + newnode->link=NULL; } - newnode->next=p->next; + newnode->link=p->link; (*head)=newnode; } @@ -47,17 +48,18 @@ void insert_end(struct circularNode** head,int a){ p=*head; newnode->data=a; while(p!=*head){ - p=p->next; + p=p->link; } if(*head==NULL){ *head=newnode; } - newnode->next=*head; - p->next=newnode; + newnode->link=*head; + p->link=newnode; } -int main(){ +int main() +{ struct circularNode* a = createnode(7); insert_front(&a, 5); show(a); diff --git a/CommonjsinterviewQuestions/app.js b/CommonjsinterviewQuestions/app.js new file mode 100644 index 00000000..b0150750 --- /dev/null +++ b/CommonjsinterviewQuestions/app.js @@ -0,0 +1,36 @@ + +/* I will add here every day one or two common js interview questions and there respective answers which would + help u gain confidence and also to ace or hone up your JS skills +*/ +let obj = { + a:5, + b:function(){ + console.log(this.a); + }, + c:()=>{ + console.log(this.a); + } +}; + +let f1 = obj.b; +let f2 = obj.c; +f1(); +f2(); + +obj.b(); +obj.c(); + + +//So, answer of this above four function calling will be as follows with their explanation => + +f1() // this will print "undefined" as in after obj.b, f1 is now referencing global object window not object obj + // this.a will print undefined as with window object there is no a property defined. +f2() // this will also print "undefined" as in arrow functions "this" will refer "this" of surrounding scope + // as in arrow function "this" doesn't not get bind so if we want to know the value of this we should see + // the this just above the line we have start declaring our arrow function.Hence here "this" is referring to + // window object that's why it doesn't has any 'a' property defined with it. + +obj.b() // here it will print '5' as in regular function calling b method will get bind to object left of dot + +obj.c() // here also it will print "undefined" as in arrow function this doesn't get bind and it will see "this" of surrounding scope + // which is referring to window object and that object not have any 'a' property defined with it \ No newline at end of file diff --git a/CountSort.java b/CountSort.java new file mode 100644 index 00000000..a9635e0f --- /dev/null +++ b/CountSort.java @@ -0,0 +1,42 @@ +import java.util.Scanner; + +public class CountSort { + + static void countSort(char arr[]) + { + int n = arr.length; + char output[] = new char[n]; + + int count[] = new int[256]; + + for (int i=0; i<256; ++i) + count[i] = 0; + + for (int i=0; i=0; i--) + { + output[count[arr[i]]-1] = arr[i]; + --count[arr[i]]; + } + + + for (int i = 0; i +# +# **W1** +# [[ 0.01624345 -0.00611756] +# [-0.00528172 -0.01072969]] +# +# +# +# **b1** +# [[ 0.] +# [ 0.]] +# +# +# +# **W2** +# [[ 0.00865408 -0.02301539]] +# +# +# +# **b2** +# [[ 0.]] +# +# +# + +# ### 3.2 - L-layer Neural Network +# +# The initialization for a deeper L-layer neural network is more complicated because there are many more weight matrices and bias vectors. When completing the `initialize_parameters_deep`, you should make sure that your dimensions match between each layer. Recall that $n^{[l]}$ is the number of units in layer $l$. Thus for example if the size of our input $X$ is $(12288, 209)$ (with $m=209$ examples) then: +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +#
**Shape of W** **Shape of b** **Activation** **Shape of Activation**
**Layer 1** $(n^{[1]},12288)$ $(n^{[1]},1)$ $Z^{[1]} = W^{[1]} X + b^{[1]} $ $(n^{[1]},209)$
**Layer 2** $(n^{[2]}, n^{[1]})$ $(n^{[2]},1)$ $Z^{[2]} = W^{[2]} A^{[1]} + b^{[2]}$ $(n^{[2]}, 209)$
$\vdots$ $\vdots$ $\vdots$ $\vdots$ $\vdots$
**Layer L-1** $(n^{[L-1]}, n^{[L-2]})$ $(n^{[L-1]}, 1)$ $Z^{[L-1]} = W^{[L-1]} A^{[L-2]} + b^{[L-1]}$ $(n^{[L-1]}, 209)$
**Layer L** $(n^{[L]}, n^{[L-1]})$ $(n^{[L]}, 1)$ $Z^{[L]} = W^{[L]} A^{[L-1]} + b^{[L]}$ $(n^{[L]}, 209)$
+# +# Remember that when we compute $W X + b$ in python, it carries out broadcasting. For example, if: +# +# $$ W = \begin{bmatrix} +# j & k & l\\ +# m & n & o \\ +# p & q & r +# \end{bmatrix}\;\;\; X = \begin{bmatrix} +# a & b & c\\ +# d & e & f \\ +# g & h & i +# \end{bmatrix} \;\;\; b =\begin{bmatrix} +# s \\ +# t \\ +# u +# \end{bmatrix}\tag{2}$$ +# +# Then $WX + b$ will be: +# +# $$ WX + b = \begin{bmatrix} +# (ja + kd + lg) + s & (jb + ke + lh) + s & (jc + kf + li)+ s\\ +# (ma + nd + og) + t & (mb + ne + oh) + t & (mc + nf + oi) + t\\ +# (pa + qd + rg) + u & (pb + qe + rh) + u & (pc + qf + ri)+ u +# \end{bmatrix}\tag{3} $$ + +# +# **Instructions**: +# - The model's structure is *[LINEAR -> RELU] $ \times$ (L-1) -> LINEAR -> SIGMOID*. I.e., it has $L-1$ layers using a ReLU activation function followed by an output layer with a sigmoid activation function. +# - Use random initialization for the weight matrices. Use `np.random.rand(shape) * 0.01`. +# - Use zeros initialization for the biases. Use `np.zeros(shape)`. +# - We will store $n^{[l]}$, the number of units in different layers, in a variable `layer_dims`. For example, the `layer_dims` for the "Planar Data classification model" from last week would have been [2,4,1]: There were two inputs, one hidden layer with 4 hidden units, and an output layer with 1 output unit. Thus means `W1`'s shape was (4,2), `b1` was (4,1), `W2` was (1,4) and `b2` was (1,1). Now you will generalize this to $L$ layers! +# - Here is the implementation for $L=1$ (one layer neural network). It should inspire you to implement the general case (L-layer neural network). +# ```python +# if L == 1: +# parameters["W" + str(L)] = np.random.randn(layer_dims[1], layer_dims[0]) * 0.01 +# parameters["b" + str(L)] = np.zeros((layer_dims[1], 1)) +# ``` + +# In[4]: + +# GRADED FUNCTION: initialize_parameters_deep + +def initialize_parameters_deep(layer_dims): + """ + Arguments: + layer_dims -- python array (list) containing the dimensions of each layer in our network + + Returns: + parameters -- python dictionary containing your parameters "W1", "b1", ..., "WL", "bL": + Wl -- weight matrix of shape (layer_dims[l], layer_dims[l-1]) + bl -- bias vector of shape (layer_dims[l], 1) + """ + + np.random.seed(3) + parameters = {} + L = len(layer_dims) # number of layers in the network + + for l in range(1, L): + ### START CODE HERE ### (≈ 2 lines of code) + parameters['W' + str(l)] = np.random.randn(layer_dims[l], layer_dims[l - 1]) * 0.01 + parameters['b' + str(l)] = np.zeros((layer_dims[l], 1)) + ### END CODE HERE ### + + assert (parameters['W' + str(l)].shape == (layer_dims[l], layer_dims[l - 1])) + assert (parameters['b' + str(l)].shape == (layer_dims[l], 1)) + + return parameters + + +# In[5]: + +parameters = initialize_parameters_deep([5, 4, 3]) +print("W1 = " + str(parameters["W1"])) +print("b1 = " + str(parameters["b1"])) +print("W2 = " + str(parameters["W2"])) +print("b2 = " + str(parameters["b2"])) + + +# **Expected output**: +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +#
**W1** [[ 0.01788628 0.0043651 0.00096497 -0.01863493 -0.00277388] +# [-0.00354759 -0.00082741 -0.00627001 -0.00043818 -0.00477218] +# [-0.01313865 0.00884622 0.00881318 0.01709573 0.00050034] +# [-0.00404677 -0.0054536 -0.01546477 0.00982367 -0.01101068]]
**b1** [[ 0.] +# [ 0.] +# [ 0.] +# [ 0.]]
**W2** [[-0.01185047 -0.0020565 0.01486148 0.00236716] +# [-0.01023785 -0.00712993 0.00625245 -0.00160513] +# [-0.00768836 -0.00230031 0.00745056 0.01976111]]
**b2** [[ 0.] +# [ 0.] +# [ 0.]]
+ +# ## 4 - Forward propagation module +# +# ### 4.1 - Linear Forward +# Now that you have initialized your parameters, you will do the forward propagation module. You will start by implementing some basic functions that you will use later when implementing the model. You will complete three functions in this order: +# +# - LINEAR +# - LINEAR -> ACTIVATION where ACTIVATION will be either ReLU or Sigmoid. +# - [LINEAR -> RELU] $\times$ (L-1) -> LINEAR -> SIGMOID (whole model) +# +# The linear forward module (vectorized over all the examples) computes the following equations: +# +# $$Z^{[l]} = W^{[l]}A^{[l-1]} +b^{[l]}\tag{4}$$ +# +# where $A^{[0]} = X$. +# +# **Exercise**: Build the linear part of forward propagation. +# +# **Reminder**: +# The mathematical representation of this unit is $Z^{[l]} = W^{[l]}A^{[l-1]} +b^{[l]}$. You may also find `np.dot()` useful. If your dimensions don't match, printing `W.shape` may help. + +# In[8]: + +# GRADED FUNCTION: linear_forward + +def linear_forward(A, W, b): + """ + Implement the linear part of a layer's forward propagation. + Arguments: + A -- activations from previous layer (or input data): (size of previous layer, number of examples) + W -- weights matrix: numpy array of shape (size of current layer, size of previous layer) + b -- bias vector, numpy array of shape (size of the current layer, 1) + Returns: + Z -- the input of the activation function, also called pre-activation parameter + cache -- a python dictionary containing "A", "W" and "b" ; stored for computing the backward pass efficiently + """ + + ### START CODE HERE ### (≈ 1 line of code) + Z = np.dot(W, A) + b + ### END CODE HERE ### + + assert (Z.shape == (W.shape[0], A.shape[1])) + cache = (A, W, b) + + return Z, cache + + +# In[9]: + +A, W, b = linear_forward_test_case() + +Z, linear_cache = linear_forward(A, W, b) +print("Z = " + str(Z)) + + +# **Expected output**: +# +# +# +# +# +# +# +# +#
**Z** [[ 3.26295337 -1.23429987]]
+ +# ### 4.2 - Linear-Activation Forward +# +# In this notebook, you will use two activation functions: +# +# - **Sigmoid**: $\sigma(Z) = \sigma(W A + b) = \frac{1}{ 1 + e^{-(W A + b)}}$. We have provided you with the `sigmoid` function. This function returns **two** items: the activation value "`a`" and a "`cache`" that contains "`Z`" (it's what we will feed in to the corresponding backward function). To use it you could just call: +# ``` python +# A, activation_cache = sigmoid(Z) +# ``` +# +# - **ReLU**: The mathematical formula for ReLu is $A = RELU(Z) = max(0, Z)$. We have provided you with the `relu` function. This function returns **two** items: the activation value "`A`" and a "`cache`" that contains "`Z`" (it's what we will feed in to the corresponding backward function). To use it you could just call: +# ``` python +# A, activation_cache = relu(Z) +# ``` + +# For more convenience, you are going to group two functions (Linear and Activation) into one function (LINEAR->ACTIVATION). Hence, you will implement a function that does the LINEAR forward step followed by an ACTIVATION forward step. +# +# **Exercise**: Implement the forward propagation of the *LINEAR->ACTIVATION* layer. Mathematical relation is: $A^{[l]} = g(Z^{[l]}) = g(W^{[l]}A^{[l-1]} +b^{[l]})$ where the activation "g" can be sigmoid() or relu(). Use linear_forward() and the correct activation function. + +# In[10]: + +# GRADED FUNCTION: linear_activation_forward + +def linear_activation_forward(A_prev, W, b, activation): + """ + Implement the forward propagation for the LINEAR->ACTIVATION layer + Arguments: + A_prev -- activations from previous layer (or input data): (size of previous layer, number of examples) + W -- weights matrix: numpy array of shape (size of current layer, size of previous layer) + b -- bias vector, numpy array of shape (size of the current layer, 1) + activation -- the activation to be used in this layer, stored as a text string: "sigmoid" or "relu" + Returns: + A -- the output of the activation function, also called the post-activation value + cache -- a python dictionary containing "linear_cache" and "activation_cache"; + stored for computing the backward pass efficiently + """ + + if activation == "sigmoid": + # Inputs: "A_prev, W, b". Outputs: "A, activation_cache". + ### START CODE HERE ### (≈ 2 lines of code) + Z, linear_cache = linear_forward(A_prev, W, b) + A, activation_cache = sigmoid(Z) + ### END CODE HERE ### + + elif activation == "relu": + # Inputs: "A_prev, W, b". Outputs: "A, activation_cache". + ### START CODE HERE ### (≈ 2 lines of code) + Z, linear_cache = linear_forward(A_prev, W, b) + A, activation_cache = relu(Z) + ### END CODE HERE ### + + assert (A.shape == (W.shape[0], A_prev.shape[1])) + cache = (linear_cache, activation_cache) + + return A, cache + + +# In[11]: + +A_prev, W, b = linear_activation_forward_test_case() + +A, linear_activation_cache = linear_activation_forward(A_prev, W, b, activation="sigmoid") +print("With sigmoid: A = " + str(A)) + +A, linear_activation_cache = linear_activation_forward(A_prev, W, b, activation="relu") +print("With ReLU: A = " + str(A)) + +# **Expected output**: +# +# +# +# +# +# +# +# +# +# +#
**With sigmoid: A ** [[ 0.96890023 0.11013289]]
**With ReLU: A ** [[ 3.43896131 0. ]]
+# + +# **Note**: In deep learning, the "[LINEAR->ACTIVATION]" computation is counted as a single layer in the neural network, not two layers. + +# ### d) L-Layer Model +# +def L_model_forward(X, parameters): + """ + Implement forward propagation for the [LINEAR->RELU]*(L-1)->LINEAR->SIGMOID computation + + Arguments: + X -- data, numpy array of shape (input size, number of examples) + parameters -- output of initialize_parameters_deep() + + Returns: + AL -- last post-activation value + caches -- list of caches containing: + every cache of linear_relu_forward() (there are L-1 of them, indexed from 0 to L-2) + the cache of linear_sigmoid_forward() (there is one, indexed L-1) + """ + + caches = [] + A = X + L = len(parameters) // 2 # number of layers in the neural network + + # Implement [LINEAR -> RELU]*(L-1). Add "cache" to the "caches" list. + for l in range(1, L): + A_prev = A + ### START CODE HERE ### (≈ 2 lines of code) + A, cache = linear_activation_forward(A_prev, parameters['W' + str(l)], parameters['b' + str(l)], + activation="relu") + caches.append(cache) + ### END CODE HERE ### + + # Implement LINEAR -> SIGMOID. Add "cache" to the "caches" list. + ### START CODE HERE ### (≈ 2 lines of code) + AL, cache = linear_activation_forward(A, parameters['W' + str(L)], parameters['b' + str(L)], activation="sigmoid") + caches.append(cache) + ### END CODE HERE ### + + assert (AL.shape == (1, X.shape[1])) + + return AL, caches + + +# In[25]: + +X, parameters = L_model_forward_test_case() +AL, caches = L_model_forward(X, parameters) +print("AL = " + str(AL)) +print("Length of caches list = " + str(len(caches))) + + +# +# +# +# +# +# +# +# +# +#
**AL** [[ 0.17007265 0.2524272 ]]
**Length of caches list ** 2
+ +# GRADED FUNCTION: compute_cost + +def compute_cost(AL, Y): + """ + Implement the cost function defined by equation (7). + Arguments: + AL -- probability vector corresponding to your label predictions, shape (1, number of examples) + Y -- true "label" vector (for example: containing 0 if non-cat, 1 if cat), shape (1, number of examples) + Returns: + cost -- cross-entropy cost + """ + + m = Y.shape[1] + + # Compute loss from aL and y. + ### START CODE HERE ### (≈ 1 lines of code) + cost = -1 / m * (np.dot(Y, np.log(AL.T)) + np.dot(1 - Y, np.log(1 - AL).T)) + ### END CODE HERE ### + + cost = np.squeeze(cost) # To make sure your cost's shape is what we expect (e.g. this turns [[17]] into 17). + assert (cost.shape == ()) + + return cost + + +# In[29]: + +Y, AL = compute_cost_test_case() + +print("cost = " + str(compute_cost(AL, Y))) + + +# **Expected Output**: +# +# +# +# +# +# +# +#
**cost** 0.41493159961539694
+def linear_backward(dZ, cache): + """ + Implement the linear portion of backward propagation for a single layer (layer l) + Arguments: + dZ -- Gradient of the cost with respect to the linear output (of current layer l) + cache -- tuple of values (A_prev, W, b) coming from the forward propagation in the current layer + Returns: + dA_prev -- Gradient of the cost with respect to the activation (of the previous layer l-1), same shape as A_prev + dW -- Gradient of the cost with respect to W (current layer l), same shape as W + db -- Gradient of the cost with respect to b (current layer l), same shape as b + """ + A_prev, W, b = cache + m = A_prev.shape[1] + + ### START CODE HERE ### (≈ 3 lines of code) + dW = 1 / m * (np.dot(dZ, A_prev.T)) + db = 1 / m * (np.sum(dZ, axis=1, keepdims=True)) + dA_prev = np.dot(W.T, dZ) + ### END CODE HERE ### + + assert (dA_prev.shape == A_prev.shape) + assert (dW.shape == W.shape) + assert (db.shape == b.shape) + + return dA_prev, dW, db + + +# In[33]: + +# Set up some test inputs +dZ, linear_cache = linear_backward_test_case() + +dA_prev, dW, db = linear_backward(dZ, linear_cache) +print("dA_prev = " + str(dA_prev)) +print("dW = " + str(dW)) +print("db = " + str(db)) + + +# **Expected Output**: +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +#
**dA_prev** [[ 0.51822968 -0.19517421] +# [-0.40506361 0.15255393] +# [ 2.37496825 -0.89445391]]
**dW** [[-0.10076895 1.40685096 1.64992505]]
**db** [[ 0.50629448]]
+# +# +def linear_activation_backward(dA, cache, activation): + """ + Implement the backward propagation for the LINEAR->ACTIVATION layer. + + Arguments: + dA -- post-activation gradient for current layer l + cache -- tuple of values (linear_cache, activation_cache) we store for computing backward propagation efficiently + activation -- the activation to be used in this layer, stored as a text string: "sigmoid" or "relu" + + Returns: + dA_prev -- Gradient of the cost with respect to the activation (of the previous layer l-1), same shape as A_prev + dW -- Gradient of the cost with respect to W (current layer l), same shape as W + db -- Gradient of the cost with respect to b (current layer l), same shape as b + """ + linear_cache, activation_cache = cache + + if activation == "relu": + ### START CODE HERE ### (≈ 2 lines of code) + dZ = relu_backward(dA, activation_cache) + dA_prev, dW, db = linear_backward(dZ, linear_cache) + ### END CODE HERE ### + + elif activation == "sigmoid": + ### START CODE HERE ### (≈ 2 lines of code) + dZ = sigmoid_backward(dA, activation_cache) + dA_prev, dW, db = linear_backward(dZ, linear_cache) + ### END CODE HERE ### + + return dA_prev, dW, db + + +# In[35]: + +AL, linear_activation_cache = linear_activation_backward_test_case() + +dA_prev, dW, db = linear_activation_backward(AL, linear_activation_cache, activation="sigmoid") +print("sigmoid:") +print("dA_prev = " + str(dA_prev)) +print("dW = " + str(dW)) +print("db = " + str(db) + "\n") + +dA_prev, dW, db = linear_activation_backward(AL, linear_activation_cache, activation="relu") +print("relu:") +print("dA_prev = " + str(dA_prev)) +print("dW = " + str(dW)) +print("db = " + str(db)) + + +# **Expected output with sigmoid:** +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +#
dA_prev [[ 0.11017994 0.01105339] +# [ 0.09466817 0.00949723] +# [-0.05743092 -0.00576154]]
dW [[ 0.10266786 0.09778551 -0.01968084]]
db [[-0.05729622]]
+# +# + +# **Expected output with relu** +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +#
dA_prev [[ 0.44090989 0. ] +# [ 0.37883606 0. ] +# [-0.2298228 0. ]]
dW [[ 0.44513824 0.37371418 -0.10478989]]
db [[-0.20837892]]
+# +# +def L_model_backward(AL, Y, caches): + """ + Implement the backward propagation for the [LINEAR->RELU] * (L-1) -> LINEAR -> SIGMOID group + + Arguments: + AL -- probability vector, output of the forward propagation (L_model_forward()) + Y -- true "label" vector (containing 0 if non-cat, 1 if cat) + caches -- list of caches containing: + every cache of linear_activation_forward() with "relu" (it's caches[l], for l in range(L-1) i.e l = 0...L-2) + the cache of linear_activation_forward() with "sigmoid" (it's caches[L-1]) + + Returns: + grads -- A dictionary with the gradients + grads["dA" + str(l)] = ... + grads["dW" + str(l)] = ... + grads["db" + str(l)] = ... + """ + grads = {} + L = len(caches) # the number of layers + m = AL.shape[1] + Y = Y.reshape(AL.shape) # after this line, Y is the same shape as AL + + # Initializing the backpropagation + ### START CODE HERE ### (1 line of code) + dAL = - (np.divide(Y, AL) - np.divide(1 - Y, 1 - AL)) + ### END CODE HERE ### + + # Lth layer (SIGMOID -> LINEAR) gradients. Inputs: "AL, Y, caches". Outputs: "grads["dAL"], grads["dWL"], grads["dbL"] + ### START CODE HERE ### (approx. 2 lines) + current_cache = caches[L - 1] + grads["dA" + str(L)], grads["dW" + str(L)], grads["db" + str(L)] = linear_activation_backward(dAL, current_cache, + activation="sigmoid") + ### END CODE HERE ### + + for l in reversed(range(L - 1)): + # lth layer: (RELU -> LINEAR) gradients. + # Inputs: "grads["dA" + str(l + 2)], caches". Outputs: "grads["dA" + str(l + 1)] , grads["dW" + str(l + 1)] , grads["db" + str(l + 1)] + ### START CODE HERE ### (approx. 5 lines) + current_cache = caches[l] + dA_prev_temp, dW_temp, db_temp = linear_activation_backward(grads["dA" + str(L)], current_cache, + activation="relu") + grads["dA" + str(l + 1)] = dA_prev_temp + grads["dW" + str(l + 1)] = dW_temp + grads["db" + str(l + 1)] = db_temp + ### END CODE HERE ### + + return grads + + +# In[39]: + +AL, Y_assess, caches = L_model_backward_test_case() +grads = L_model_backward(AL, Y_assess, caches) +print("dW1 = " + str(grads["dW1"])) +print("db1 = " + str(grads["db1"])) +print("dA1 = " + str(grads["dA1"])) + + +# **Expected Output** +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +#
dW1 [[ 0.41010002 0.07807203 0.13798444 0.10502167] +# [ 0. 0. 0. 0. ] +# [ 0.05283652 0.01005865 0.01777766 0.0135308 ]]
db1 [[-0.22007063] +# [ 0. ] +# [-0.02835349]]
dA1 [[ 0. 0.52257901] +# [ 0. -0.3269206 ] +# [ 0. -0.32070404] +# [ 0. -0.74079187]]
+# +# + +def update_parameters(parameters, grads, learning_rate): + """ + Update parameters using gradient descent + + Arguments: + parameters -- python dictionary containing your parameters + grads -- python dictionary containing your gradients, output of L_model_backward + + Returns: + parameters -- python dictionary containing your updated parameters + parameters["W" + str(l)] = ... + parameters["b" + str(l)] = ... + """ + + L = len(parameters) // 2 # number of layers in the neural network + + # Update rule for each parameter. Use a for loop. + ### START CODE HERE ### (≈ 3 lines of code) + for l in range(L): + parameters["W" + str(l + 1)] = parameters["W" + str(l + 1)] - learning_rate * grads["dW" + str(l + 1)] + parameters["b" + str(l + 1)] = parameters["b" + str(l + 1)] - learning_rate * grads["db" + str(l + 1)] + ### END CODE HERE ### + + return parameters + + +# In[42]: + +parameters, grads = update_parameters_test_case() +parameters = update_parameters(parameters, grads, 0.1) + +print("W1 = " + str(parameters["W1"])) +print("b1 = " + str(parameters["b1"])) +print("W2 = " + str(parameters["W2"])) +print("b2 = " + str(parameters["b2"])) + + +# **Expected Output**: +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +# +#
W1 [[-0.59562069 -0.09991781 -2.14584584 1.82662008] +# [-1.76569676 -0.80627147 0.51115557 -1.18258802] +# [-1.0535704 -0.86128581 0.68284052 2.20374577]]
b1 [[-0.04659241] +# [-1.28888275] +# [ 0.53405496]]
W2 [[-0.55569196 0.0354055 1.32964895]]
b2 [[-0.84610769]]
+# + +# diff --git a/Dijkstra's Algorithm/djistra.java b/Dijkstra's Algorithm/djistra.java new file mode 100644 index 00000000..3852120c --- /dev/null +++ b/Dijkstra's Algorithm/djistra.java @@ -0,0 +1,87 @@ +import java.util.Scanner; //Scanner Function to take in the Input Values + +public class Dijkstra +{ + static Scanner scan; // scan is a Scanner Object + + public static void main(String[] args) + { + int[] preD = new int[5]; + int min = 999, nextNode = 0; // min holds the minimum value, nextNode holds the value for the next node. + scan = new Scanner(System.in); + int[] distance = new int[5]; // the distance matrix + int[][] matrix = new int[5][5]; // the actual matrix + int[] visited = new int[5]; // the visited array + + System.out.println("Enter the cost matrix"); + + for (int i = 0; i < distance.length; i++) + { + visited[i] = 0; //initialize visited array to zeros + preD[i] = 0; + + for (int j = 0; j < distance.length; j++) + { + matrix[i][j] = scan.nextInt(); //fill the matrix + if (matrix[i][j]==0) + matrix[i][j] = 999; // make the zeros as 999 + } + } + + distance = matrix[0]; //initialize the distance array + visited[0] = 1; //set the source node as visited + distance[0] = 0; //set the distance from source to source to zero which is the starting point + + for (int counter = 0; counter < 5; counter++) + { + min = 999; + for (int i = 0; i < 5; i++) + { + if (min > distance[i] && visited[i]!=1) + { + min = distance[i]; + nextNode = i; + } + } + + visited[nextNode] = 1; + for (int i = 0; i < 5; i++) + { + if (visited[i]!=1) + { + if (min+matrix[nextNode][i] < distance[i]) + { + distance[i] = min+matrix[nextNode][i]; + preD[i] = nextNode; + } + + } + + } + + } + + for(int i = 0; i < 5; i++) + System.out.print("|" + distance[i]); + + System.out.println("|"); + + int j; + for (int i = 0; i < 5; i++) + { + if (i!=0) + { + + System.out.print("Path = " + i); + j = i; + do + { + j = preD[j]; + System.out.print(" <- " + j); + } + while(j != 0); + } + System.out.println(); + } + } +} diff --git a/FCFS.CPP b/FCFS.CPP new file mode 100644 index 00000000..5c0c8501 --- /dev/null +++ b/FCFS.CPP @@ -0,0 +1,41 @@ +#include +#include + +void TurnArroundTime(int arr[],int p) +{ int j=0; + int max; + int tat=0; + int wt=0; + float totaltat=0,totalwt=0; + + for(j;j using namespace std; -int factorial(int); +int faktorial(int); int main() { int n; cin >> n; - cout << "Factorial of the entered no. is :" << factorial(n); + cout << "Faktorial dari angka tersebut adalah :" << factorial(n); } -int factorial(int n) +int faktorial(int n) { if (n==0) { return 1; } - return n * factorial(n-1); + return n * faktorial(n-1); } diff --git a/Factorial.java b/Factorial.java new file mode 100644 index 00000000..07dd4a6c --- /dev/null +++ b/Factorial.java @@ -0,0 +1,26 @@ +import java.util.Scanner; + +class Factorial +{ + public static void main(String args[]) + { + int a; + int c; + int fact = 1; + + System.out.println(" Enter an integer "); + Scanner sc = new Scanner(System.in); + + a = sc.nextInt(); + + if (a < 0) + System.out.println("Number should be non-negative."); + else + { + for (c = 1; c <= a; c++) + fact = fact*c; + + System.out.println("Factorial of "+a+" is = "+fact); + } + } +} diff --git a/FactorialFinding.java b/FactorialFinding.java new file mode 100644 index 00000000..279158c3 --- /dev/null +++ b/FactorialFinding.java @@ -0,0 +1,26 @@ +import java.util.Scanner; + +public class FactorialFinding +{ + public static void main(String args[]) + { + + int c; + int fact = 1; + + System.out.println(" Enter an integer to calculate it's factorial"); + Scanner sc = new Scanner(System.in); + + int n = sc.nextInt(); + + if (n < 0) + System.out.println("Number should be positive."); + else + { + for (c = 1; c <= n; c++) + fact = fact*c; + + System.out.println("Factorial of "+n+" is = "+fact); + } + } +} diff --git a/Fatorial_finding.java b/Fatorial_finding.java index 6d193c77..d5a366c3 100644 --- a/Fatorial_finding.java +++ b/Fatorial_finding.java @@ -2,11 +2,13 @@ class Factorial_finding { - public static void main(String args[]) + public static void main(String...args) { - int n, c, fact = 1; + int n; + int c; + int fact = 1; - System.out.println("Enter an integer to calculate it's factorial"); + System.out.println(" Enter an integer to calculate it's factorial"); Scanner in = new Scanner(System.in); n = in.nextInt(); @@ -21,4 +23,4 @@ public static void main(String args[]) System.out.println("Factorial of "+n+" is = "+fact); } } -} \ No newline at end of file +} diff --git a/Fibonacci.cpp b/Fibonacci.cpp index 13ec1f85..df9592e0 100644 --- a/Fibonacci.cpp +++ b/Fibonacci.cpp @@ -2,7 +2,7 @@ #include using namespace std; -int main(int argc, char const *argv[]) +int main() { int nc, count=0, sum; int first, second; diff --git a/Fibonacci_Series b/Fibonacci_Series new file mode 100644 index 00000000..df136cad --- /dev/null +++ b/Fibonacci_Series @@ -0,0 +1,17 @@ +class Fibonacci{ + static int num1=0,num2=1,num3=0; + static void findFibonacci(int count){ + if(count>0){ + num3 = num1 + num2; + num1 = num2; + num2 = num3; + System.out.print(" "+num3); + printFibonacci(count-1); + } + } + public static void main(String args[]){ + int count=10; + System.out.print(num1+" "+num2); + findFibonacci(count-2); + } +} diff --git a/Game_Of_Life_in_C/Game b/Game_Of_Life_in_C/Game new file mode 100755 index 00000000..d5fe9ab2 Binary files /dev/null and b/Game_Of_Life_in_C/Game differ diff --git a/Game_Of_Life_in_C/README.md b/Game_Of_Life_in_C/README.md new file mode 100644 index 00000000..f2bbd09e --- /dev/null +++ b/Game_Of_Life_in_C/README.md @@ -0,0 +1,5 @@ +**TEST** + +in order to test this binary. run + ./Game +this shows the usage. diff --git a/Game_Of_Life_in_C/Sample_initialState b/Game_Of_Life_in_C/Sample_initialState new file mode 100644 index 00000000..5004b6c9 --- /dev/null +++ b/Game_Of_Life_in_C/Sample_initialState @@ -0,0 +1,20 @@ +1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, +1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, +1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0, diff --git a/Game_Of_Life_in_C/makefile b/Game_Of_Life_in_C/makefile new file mode 100644 index 00000000..22510da4 --- /dev/null +++ b/Game_Of_Life_in_C/makefile @@ -0,0 +1,2 @@ +all: + gcc -o Game src/GameOfLife.c diff --git a/Game_Of_Life_in_C/src/GameOfLife.c b/Game_Of_Life_in_C/src/GameOfLife.c new file mode 100644 index 00000000..a0409437 --- /dev/null +++ b/Game_Of_Life_in_C/src/GameOfLife.c @@ -0,0 +1,190 @@ +#include +#include +#include +#include +#include +#include +#include "GameOfLife.h" + +#define DISPLAY 1 + +/* + * rules of the game of life + * > less than two neighbours dies + * > two or three neighbours lives + * > three neighbours resuract a cell + * > more than 3 neighbours dies + */ + +int main(int argc, char * argv[]) { + FILE *initFile; + char *buffer = NULL; + char *token; + const char delim[2] = ","; + char **strret; + int x = 0, y = 0; + size_t bufferLength; + size_t read; + size_t init = 0; + long int iteration = 0; + Cell current_generation[MATRIXSIZE][MATRIXSIZE]; + Cell future_generation[MATRIXSIZE][MATRIXSIZE]; + + if (argc != 3){ + printf("Usage: Game File Num\n"); + printf("\n"); + printf("\tFile: file containing the initial state.\n"); + printf("\tNum: number of generation.\n"); + exit(1); + } + + int len = strlen(argv[2]); + char * argument; + argument = malloc(sizeof(char)*len + 1); + + strcpy(argument, argv[2]); + + for (int i = 0;argument[i] != '\0'; i++) + { + if (!(isdigit(argument[i]))) + { + printf("Wrong iteration number\n"); + exit(1); + } + } + + iteration = strtol(argument,strret,10); + + free(argument); + + if ((initFile=fopen(argv[1],"r")) == NULL){ + printf("Error opening file\n"); + exit(1); + } + + //get the initial state from a file + while(getline(&buffer,&bufferLength,initFile) != -1){ + token = strtok(buffer,delim); + while (token != NULL){ + if (strcmp(token,"\n") != 0){ + if(strcmp(token,"0") == 0){ + current_generation[x][y] = dead; + y++; + } + else if (strcmp(token,"1") == 0){ + current_generation[x][y] = alive; + y++; + } + else + { + printf("unknown string\n"); + exit(1); + } + } + token = strtok(NULL,delim); + } + y = 0; + x++; + } + + if(DISPLAY) printLife(current_generation); +// game of life + while (iteration > 0) { + Live(current_generation,future_generation); + + for (int i = 0; i < MATRIXSIZE; i++) + { + for (int j = 0; j < MATRIXSIZE; j++) + { + current_generation[i][j] = future_generation[i][j]; + } + } + if(DISPLAY) printLife(future_generation); + iteration--; + } + + fclose(initFile); +} + +void printLife(Cell cellp[MATRIXSIZE][MATRIXSIZE] ){ + for (int i = 0; i < MATRIXSIZE; i++) + { + for (int j = 0; j < MATRIXSIZE; j++) + { + if (cellp[i][j] == dead) + printf(". "); + else + printf("* "); + } + printf("\n" ); + } + printf("\n" ); +} + +void Live(Cell current_generation[MATRIXSIZE][MATRIXSIZE], Cell future_generation[MATRIXSIZE][MATRIXSIZE]) +{ + int neighbours = 0; + + for (int i = 0; i < MATRIXSIZE; i++) + { + for (int j = 0; j < MATRIXSIZE; j++) + { + if( i != 0 ) + { + if (current_generation[i-1][j] == alive) neighbours++; + if (j != MATRIXSIZE-1) + { + if (current_generation[i-1][j+1] == alive) neighbours++; + } + if ( j != 0 ) + { + if (current_generation[i-1][j-1] == alive) neighbours++; + + } + + } + + if (j != 0) + { + if (current_generation[i][j-1] == alive) neighbours++; + + if (i != MATRIXSIZE-1) + { + if (current_generation[i+1][j-1] == alive) neighbours++; + } + + } + + if (i != MATRIXSIZE-1) + { + if (j != MATRIXSIZE-1) + { + if (current_generation[i+1][j+1] == alive) neighbours++; + } + if (current_generation[i+1][j] == alive) neighbours++; + } + + if (j != MATRIXSIZE-1) + { + if (current_generation[i][j+1] == alive) neighbours++; + } + + //game rules + if (neighbours < 2) + future_generation[i][j] = dead; + else if (neighbours == 2) + { + if (current_generation[i][j] == alive) + future_generation[i][j] = alive; + else + future_generation[i][j] = dead; + } + else if (neighbours == 3) + future_generation[i][j] = alive; + else if (neighbours > 3) + future_generation[i][j] = dead; + + neighbours = 0; + } + } +} diff --git a/Game_Of_Life_in_C/src/GameOfLife.h b/Game_Of_Life_in_C/src/GameOfLife.h new file mode 100644 index 00000000..ed3e4973 --- /dev/null +++ b/Game_Of_Life_in_C/src/GameOfLife.h @@ -0,0 +1,5 @@ +#define MATRIXSIZE 20 +typedef enum {alive, dead} Cell; +void printLife(Cell cellp[MATRIXSIZE][MATRIXSIZE]); +void Live(Cell current_generation[MATRIXSIZE][MATRIXSIZE], Cell future_generation[MATRIXSIZE][MATRIXSIZE]); + diff --git a/Generic-Tree.java b/Generic-Tree.java new file mode 100644 index 00000000..ebbe5253 --- /dev/null +++ b/Generic-Tree.java @@ -0,0 +1,76 @@ +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.Queue; +import java.util.Scanner; + +public class GenericTree { + private class Node { + int data; + ArrayList children; + + Node(int data) { + this.data = data; + children = new ArrayList<>(); + } + } + + private Node root; + private int size = 0; + + GenericTree() { + Scanner s = new Scanner(System.in); + this.root = takeInput(s, null, 0); + } +private Node takeInput(Scanner s, Node parent, int ithchild) { + if (parent == null) { + System.out.println("Enter the data for root Node"); + } else { + System.out.println("Enter the data for " + ithchild + " th child of " + parent.data); + } + int nodeData = s.nextInt(); + Node node = new Node(nodeData); + this.size++; + System.out.println("Please enter the number of children for " + node.data); + int numChildren = s.nextInt(); + for (int i = 0; i < numChildren; i++) { + Node child = this.takeInput(s, node, i); + node.children.add(child); + } + return node; + } + public int height() { + return this.height(this.root); + } + + private int height(Node node) { + int height = -1; + for (int i = 0; i < node.children.size(); i++) { + int heightofchild = this.height(node.children.get(i)); + if (heightofchild > height) { + height = heightofchild; + } + } + height = height + 1; + return height; + + } +} + + public int size() { + return this.size; + } + + public void display() { + this.display(this.root); + } + + private void display(Node node) { + System.out.print(node.data + "=>"); + for (int i = 0; i < node.children.size(); i++) { + System.out.print(node.children.get(i).data + ","); + } + System.out.println("END"); + for (int i = 0; i < node.children.size(); i++) { + this.display(node.children.get(i)); + } + } diff --git a/HELLO WORLD b/HELLO WORLD new file mode 100644 index 00000000..5bfc0e7c --- /dev/null +++ b/HELLO WORLD @@ -0,0 +1,8 @@ +#include +#include +void main() +{ +clrscr(); +cout<<"HELLO WORLD"; +} +##yeet diff --git a/HashMapDemo.java b/HashMapDemo.java new file mode 100644 index 00000000..a76ce4a4 --- /dev/null +++ b/HashMapDemo.java @@ -0,0 +1,97 @@ +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class HashMapDemo { + + public static void main(String[] args) { + // TODO Auto-generated method stub + HashMap map = new HashMap<>(); + map.put("India", 300); + map.put("USA", 200); + map.put("Russia", 250); + map.put("UK", 175); + map.put("China", 320); + map.put("Africa", 180); + + System.out.println(map); + + System.out.println(map.get("India")); + System.out.println(map.get("China")); + System.out.println(map.get("Ireland")); + + System.out.println(map.remove("Africa")); + + System.out.println(map.containsKey("Africa")); + + Set keys = map.keySet(); + for (String key : keys) { + System.out.println(key); + } + + Collection values = map.values(); + for (Integer value : values) { + System.out.println(value); + } + + Set> entries = map.entrySet(); + for (Map.Entry entry : entries) { + System.out.print(entry.getKey() + "=>"); + System.out.println(entry.getValue()); + } + + map.put("India", 325); + System.out.println(map); + + String str = "aaabbccddeaaa"; + System.out.println(maxFreq(str)); + + int[] arr = { 1, 3, 1, 4, 5, 2, 3, 4, 5 }; + System.out.println(getUniqueElements(arr)); + + } + + public static char maxFreq(String str) { + HashMap map = new HashMap<>(); + for (int i = 0; i < str.length(); i++) { + char cc = str.charAt(i); + if (map.containsKey(cc)) { + int ov = map.get(cc); + ov = ov + 1; + map.put(cc, ov); + } else { + map.put(cc, 1); + } + } + + Set> entries = map.entrySet(); + int maxValue = 0; + char maxChar = '\0'; + + for (Map.Entry entry : entries) { + if (entry.getValue() > maxValue) { + maxValue = entry.getValue(); + maxChar = entry.getKey(); + } + } + + return maxChar; + } + + public static ArrayList getUniqueElements(int[] arr) { + HashMap map = new HashMap<>(); + for (int value : arr) { + map.put(value, 1); + } + ArrayList list = new ArrayList<>(); + Set keys = map.keySet(); + for (Integer key : keys) { + list.add(key); + } + + return list; + } + +} diff --git a/HelloWorld.cpp b/HelloWorld.cpp new file mode 100644 index 00000000..6d9ef56a --- /dev/null +++ b/HelloWorld.cpp @@ -0,0 +1,8 @@ +#include +using namespace std; + +int main() +{ + cout<<"Hello world \n"; + return 0; +} diff --git a/Interest Calculator b/Interest Calculator new file mode 100644 index 00000000..97b1d383 --- /dev/null +++ b/Interest Calculator @@ -0,0 +1,15 @@ +print ("Hi, I am Hermione Granger.") +Name = input("And you are?") +print ("Hi {}. It's a pleasure to meet you." .format(Name)) +print ("{}, I am quite good at calculating the amount of interest one would get on an amount on a certain rate and in certain years." .format(Name)) +print ("I aspire to become the CEO of a bank.") +print ("So, to test my knowledge, You have to give me the details and then i will calculate the interest for you. Let's start") +sum = int(input ("Enter the Amount=")) +year= int(input("Enter the number of years=")) +rate = int(input ("Enter the rate of interest=")) +calculation = sum*year*rate +total = calculation/100 +print ("The interest in {} years will be {}" . format(year,total)) +print ("See? It was that easy.Well, see you later.") +print ("BYE") +exitProgram = input ("Press any letter and enter to exit.") diff --git a/LINEAR.CPP b/LINEAR.CPP new file mode 100644 index 00000000..cc42ce07 --- /dev/null +++ b/LINEAR.CPP @@ -0,0 +1,39 @@ +#include +#include +void linear(int ar[],int n,int x); +void main() +{ + clrscr(); + int ar[20],n,x; + cout<<"Enter no. of elements:"<>n; + cout<<"Enter elements:"<>ar[i]; + } + cout<<"Enter no. to be searched:"<>x; + linear(ar,n,x); + getch(); +} +void linear(int ar[],int n,int x) +{ + int flag=0,i; + for(i=0;i + + + + + diff --git a/Linear Search using C/Linear Search using C.depend b/Linear Search using C/Linear Search using C.depend new file mode 100644 index 00000000..bf2de245 --- /dev/null +++ b/Linear Search using C/Linear Search using C.depend @@ -0,0 +1,5 @@ +# depslib dependency file v1.0 +1539874679 source:c:\users\lahiru\desktop\lahirugithub\project4\hacktoberfest2018\linear search using c\main.c + + + diff --git a/Linear Search using C/Linear Search using C.layout b/Linear Search using C/Linear Search using C.layout new file mode 100644 index 00000000..fe0b1db8 --- /dev/null +++ b/Linear Search using C/Linear Search using C.layout @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Linear Search using C/bin/Debug/Linear Search using C.exe b/Linear Search using C/bin/Debug/Linear Search using C.exe new file mode 100644 index 00000000..be30e23e Binary files /dev/null and b/Linear Search using C/bin/Debug/Linear Search using C.exe differ diff --git a/Linear Search using C/main.c b/Linear Search using C/main.c new file mode 100644 index 00000000..229c56e0 --- /dev/null +++ b/Linear Search using C/main.c @@ -0,0 +1,30 @@ +#include +#include + +int main() +{ + + int x,y,z; + printf("Enter Array size="); + scanf("%d",&x); + int arr[x]; + for(y=0;y + +class Node { +private: + int data; + Node *next; +public: + Node() {}; + int getData(); + void setData(int data); + Node* getNext(); + void setNext(Node *next); +}; + +int Node::getData() { + return this->data; +} + +void Node::setData(int data) { + this->data = data; +} + +Node* Node::getNext() { + return this->next; +} + +void Node::setNext(Node *next) { + this->next = next; +} + + +class LinkedList { +private: + Node *head; + int len; +public: + LinkedList(); + void addNodeToFront(int data); + void addNodeToBack(int data); + void print(); + int getLen(); +}; + +LinkedList::LinkedList() { + head = nullptr; + len = 0; +} + +void LinkedList::addNodeToFront(int data) { + Node *newNode = new Node(); + newNode->setData(data); + newNode->setNext(head); + head = newNode; + this->len++; +} + +void LinkedList::addNodeToBack(int data) { + Node *newNode = new Node(); + newNode->setData(data); + newNode->setNext(nullptr); + Node *temp = head; + if(temp) { + while(temp->getNext()) { + temp = temp->getNext(); + } + temp->setNext(newNode); + } + else { + addNodeToFront(data); + } + this->len++; +} + +int LinkedList::getLen() { + return this->len; +} + +void LinkedList::print() { + std::cout << "Length: " << this->getLen() << "\n"; + Node *temp = head; + while(temp) { + std::cout << temp->getData() << " "; + temp = temp->getNext(); + } + std::cout << std::endl; +} + + +int main() { + LinkedList *ll = new LinkedList(); + ll->addNodeToFront(10); + ll->addNodeToFront(20); + ll->addNodeToFront(30); + ll->addNodeToBack(40); + ll->addNodeToBack(50); + ll->print(); + return 0; +} diff --git a/MERGE.CPP b/MERGE.CPP new file mode 100644 index 00000000..d3fc493b --- /dev/null +++ b/MERGE.CPP @@ -0,0 +1,77 @@ +#include +#include +void print(int ar[],int n); +void mergeSort(int ar[],int low,int high); +void merge(int ar[],int low,int mid,int high); +void main() +{ + clrscr(); + int ar[20],n,i; + cout<<"Enter no. of elements."<>n; + cout<<"Enter elements"<>ar[i]; + } + mergeSort(ar,0,n-1); + cout<<"Sorted elements are:"< +#include +int min(int i,int j,int k) +{ + if(i<=j && i<=k) + { + return i; + } + if(j<=k && j<=i) + { + return j; + } + if(k<=j && k<=i) + { + return k; + } +} + +int main() +{ + int i,j,mat[102][102] = {0}; + + char str1[101],str2[101]; + + scanf("%s",&str1); + scanf("%s",&str2); + + + for(i=0 ;i <= strlen(str1) ;i++) + { + mat[0][i] = i ; + + } + for(i=0 ;i <= strlen(str2);i++) + { + mat[i][0] = i; + + } + + + for(i=1;i <= strlen(str2);i++) + { + for(j=1;j <= strlen(str1);j++) + { + if(str2[i-1]==str1[j-1]) + { + mat[i][j] = mat[i-1][j-1]; + } + else + { + mat[i][j] = min(mat[i-1][j-1],mat[i][j-1],mat[i-1][j]) + 1; + } + + } + + } + + + printf("%d",mat[strlen(str2)][strlen(str1)]); + + return 0; +} diff --git a/PHP/PerfectSquare.php b/PHP/PerfectSquare.php new file mode 100644 index 00000000..4f52a4dd --- /dev/null +++ b/PHP/PerfectSquare.php @@ -0,0 +1,16 @@ +)'; +} + + +function isPerfectSquare($input) +{ + $input = intval($input); + return gmp_perfect_square($input); +} diff --git a/Palindrome.java b/Palindrome.java new file mode 100644 index 00000000..ecb0de91 --- /dev/null +++ b/Palindrome.java @@ -0,0 +1,59 @@ +import java.util.Scanner; +import java.util.ArrayList; + + + +public class Palindrome { + + public static int getInput() { + Scanner sc = new Scanner(System.in); + System.out.println("Enter the your number: "); + + int number = sc.nextInt(); + sc.close(); + return number; + } + + public static boolean checklist(ArrayList num, int digits) { + int x = 0; + int y = digits - 1; + while (x < digits / 2) { + if (num.get(x) == num.get(y)) { + x += 1; + y -= 1; + } else { + return false; + } + } + return true; + } + + public static void main(String[] args) { + + int number = Main.getInput(); + + // determining number of digits + int digits = 1; + int divider = number; + while (divider / 10 >= 1) { + divider /= 10; + digits += 1; + } + + // listing digits of number + ArrayList num = new ArrayList<>(); + while (number > 0) { + num.add(number % 10); + number /= 10; + } + + // check for palindrome + boolean palin = Main.checklist(num, digits); + if (palin) { + System.out.println("Number is a palindrome"); + } else { + System.out.println("Number is not a palindrome"); + } + + } +} diff --git a/Pallindrome.py b/Pallindrome.py index 1fb13b5a..bf75fb84 100644 --- a/Pallindrome.py +++ b/Pallindrome.py @@ -1,8 +1,8 @@ print("Enter the string to check") -t = input("Please enter a string") + t = input("Please enter a string") if(t == t[::-1]): - print("The string entered is palindrome") + print("The string entered is palindrome") else: - print("Not a palindrome") \ No newline at end of file + print("Not a palindrome") diff --git a/Prime_No.py b/Prime_No.py index d5243879..60ce98b7 100644 --- a/Prime_No.py +++ b/Prime_No.py @@ -1,5 +1,5 @@ l=[1,2] -import time + n=int(input()) for i in range(3,n): if i%2==0: @@ -10,7 +10,6 @@ break elif j==i: l.append(j) - #print(j,end=" ") else: pass l.sort(key=int) diff --git a/Quiz b/Quiz new file mode 100644 index 00000000..3c38cbae --- /dev/null +++ b/Quiz @@ -0,0 +1,83 @@ +import java.util.Arrays; +import java.util.List; +import java.util.Scanner; +import java.util.Collections; + +public class Quiz +{ + String question; + String answer; + int correct = 0, number; + Quiz[] quizAdd = new Quiz[8]; + List quizList = Arrays.asList(quizAdd); + + public static void main(String[] args) + { + Quiz add = new Quiz(); + add.addList(); + add.newQuestion(); + } + + public void addList() + { + quizAdd[0] = new Quiz(); + quizAdd[0].question = "What type of creature is a gecko? \n Bird, Fish, Lizard, Monkey"; + quizAdd[0].answer = "Lizard"; + + quizAdd[1] = new Quiz(); + quizAdd[1].question = "What is 1004 divided by 2? \n 52, 502, 520, 5002"; + quizAdd[1].answer = "502"; + + quizAdd[2] = new Quiz(); + quizAdd[2].question = "Which year did Titanic sink? \n 1912, 1913, 1921, 1997"; + quizAdd[2].answer = "1912"; + + quizAdd[3] = new Quiz(); + quizAdd[3].question = "How many teeth does an adult have? \n 29, 32, 33, 36"; + quizAdd[3].answer = "32"; + + quizAdd[4] = new Quiz(); + quizAdd[4].question = "How many continents are there in the world? \n 3, 6, 7, 9"; + quizAdd[4].answer = "7"; + + quizAdd[5] = new Quiz(); + quizAdd[5].question = "When did the movie Frozen come out in Sweden? \n 2010, 2011, 2013, 2014"; + quizAdd[5].answer = "2014"; + + quizAdd[6] = new Quiz(); + quizAdd[6].question = "What are minions? \n Characters, Sweets, Drinks, Colors"; + quizAdd[6].answer = "Characters"; + + quizAdd[7] = new Quiz(); + quizAdd[7].question = "What is the capital of Peru? \n Peru, Lima, Loreto, Sucre"; + quizAdd[7].answer = "Lima"; + + Collections.shuffle(quizList); + } + + public void newQuestion() + { + Scanner input = new Scanner(System.in); + System.out.println(" Welcome to this quiz "); + System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + + for (number=1; number<6; number++) + { + System.out.printf("%d. %s?%n", number, quizAdd[number].question); + String entered = input.nextLine(); + + if (entered.compareTo(quizAdd[number].answer)==0) + { + System.out.println("*** Correct! You get 1 point ***"); + correct = correct + 1; + } + else + System.out.println("--- Incorrect! You get 0 points ---"); + } + + System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~"); + System.out.printf(" Your result is %d/%d%n", correct, number-1); + System.out.println("*************************"); + } + +} diff --git a/README.md b/README.md index b7ed4d83..36b038c9 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,8 @@ + Telephone number validator. ## Getting Started -* Add Your Name to the CONTRIBUTORS.md file using following model + +* Add your name to the CONTRIBUTORS.md file using following model ```markdown Name: [YOUR NAME](Github Link) diff --git a/RSA.java b/RSA.java new file mode 100644 index 00000000..d9f37002 --- /dev/null +++ b/RSA.java @@ -0,0 +1,73 @@ +import java.io.DataInputStream; +import java.io.IOException; +import java.math.BigInteger; +import java.util.Random; + +public class RSA { + private BigInteger p; // To allow large values + private BigInteger q; + private BigInteger N; + private BigInteger phi; + private BigInteger e; + private BigInteger d; + private int bitlength = 1024; + // To create random integers create instance for Random class + private Random r; + + public RSA() { + r = new Random(); + // The java.math.BigInteger.probablePrime(int bitLength, Random rnd) returns a + // positive BigInteger that is probably prime, with the specified bitLength. + p = BigInteger.probablePrime(bitlength, r); + q = BigInteger.probablePrime(bitlength, r); + N = p.multiply(q); + phi = p.subtract(BigInteger.ONE).multiply(q.subtract(BigInteger.ONE)); + e = BigInteger.probablePrime(bitlength / 2, r); + // To generate ‘e’ so that e lies between 1 and phi + while (phi.gcd(e).compareTo(BigInteger.ONE) > 0 && e.compareTo(phi) < 0) { + e = e.add(BigInteger.ONE); + } + // To generate d as e-1 mod phi + d = e.modInverse(phi); + } + + public static void main(String[] args) throws IOException { + RSA rsa = new RSA(); + DataInputStream in = new DataInputStream(System.in); + String teststring; + System.out.println("Enter the plain text:"); + teststring = in.readLine(); + System.out.println("Encrypting String: " + teststring); + /* + * The java.lang.Byte.toString() returns a String object representing this + * Byte's value. The value is converted to signed decimal representation and + * returned as a string, exactly as if the byte value were given as an argument + * to the toString(byte) method. + */ + System.out.println("String in Bytes: " + bytesToString(teststring.getBytes())); + // encrypt + byte[] encrypted = rsa.encrypt(teststring.getBytes()); + System.out.println("encrypted string in bytes " + bytesToString(encrypted)); + // decrypt + byte[] decrypted = rsa.decrypt(encrypted); + System.out.println("Decrypting Bytes: " + bytesToString(decrypted)); + System.out.println("Decrypted String: " + new String(decrypted)); + System.out.println("****************************************"); + } + + private static String bytesToString(byte[] encrypted) { + String test = ""; + for (byte b : encrypted) { + test += Byte.toString(b); + } + return test; + } + + public byte[] encrypt(byte[] message) { + return (new BigInteger(message)).modPow(e, N).toByteArray(); + } + + public byte[] decrypt(byte[] message) { + return (new BigInteger(message)).modPow(d, N).toByteArray(); + } +} \ No newline at end of file diff --git a/RailCipher_java/RailFenceCipher.java b/RailCipher_java/RailFenceCipher.java new file mode 100644 index 00000000..afef721e --- /dev/null +++ b/RailCipher_java/RailFenceCipher.java @@ -0,0 +1,110 @@ +import java.util.*; + +public class RailFenceCipher { + + static String encode(String s, int n) { + // Your code here + String encodedString = ""; + + if (s.isEmpty()) { + return encodedString; + } + + char [][] charArray = new char[n][s.length()]; + int row = 0; + int col = 0; + boolean up = false; + for (int k = 0; k < s.length(); k++) { + charArray[row][col] = s.charAt(k); + + if (row == (n - 1)) { + up = true; + } else if (row == 0) { + up = false; + } + row = (up) ? --row : (++row); + col = ((col + 1) >= s.length()) ? 0 : (++col); + } + + for (row = 0; row < n; row++) { + for (col = 0; col < s.length(); col++) + { + if (charArray[row][col] != 0) { + encodedString += charArray[row][col]; + } + } + } + + return encodedString; + } + + static String decode(String s, int n) { + // Your code here + String decodedString = ""; + + if (s.isEmpty()) { + return decodedString; + } + + char [][] charArray = new char[n][s.length()]; + int row = 0; + int col = 0; + int l = n; + boolean up = false; + int m = row; + boolean odd = true; + int buffer = 0; + + for (int k = 0; k < s.length(); k++) + { + charArray[row][col] = s.charAt(k); + + if (row == (n - 1)) { + m = 0; + } else { + m = row; + } + + if (row == 0 || row == (n-1)) { + buffer = ((n - 2) * 2) + 2; + } else { + if (odd) { + buffer = (((n - (2 + m)) * 2) + 2); + odd = false; + } else { + buffer = ((row - 1) * 2) + 2; + odd = true; + } + } + + col += buffer; + + if (col >= s.length()) { + row++; + col = row; + odd = true; + } + } + + int j = 0; + up = false; + row = 0; + col = 0; + while (j < s.length()) { + decodedString += charArray[row][col]; + + if (row == (n - 1)) { + up = true; + } else if (row == 0) { + up = false; + } + + row = (up) ? --row : (++row); + col = ((col + 1) >= s.length()) ? 0 : (++col); + + j++; + } + + return decodedString; + } +} diff --git a/RailCipher_java/RailFenceCipherTest.java b/RailCipher_java/RailFenceCipherTest.java new file mode 100644 index 00000000..fa9e5514 --- /dev/null +++ b/RailCipher_java/RailFenceCipherTest.java @@ -0,0 +1,85 @@ +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import org.junit.runners.JUnit4; + +// TODO: Replace examples and use TDD development by writing your own tests + +public class RailFenceCipherTest { + + @Test + public void encodeSampleTests() { + String[][] encodes = {{"WEAREDISCOVEREDFLEEATONCE", "WECRLTEERDSOEEFEAOCAIVDEN"}, // 3 rails + {"Hello, World!", "Hoo!el,Wrdl l"}, // 3 rails + {"Hello, World!", "H !e,Wdloollr"}, // 4 rails + {"", ""} // 3 rails (even if...) + }; + int[] rails = {3,3,4,3}; + for (int i=0 ; i -int main()//main -{ int a[100005],count[100005],n,i,j,temp,k,var; +int main() +{ + int n,i,j,k,flag = 0; + + printf("Enter number elements in your array: "); + scanf("%d",&n); + int a[n],max = -1; + + printf("Enter array elements: "); + for(i=0;imax) + { + max = a[i]; + } + } + + + int count[max+1]; + + for(j=0;j + +void reverse(const char *str[], int n, int len) { + if(n != len) { + reverse(str, n+1, len); + printf("%s ", str[n]); + } +} + +int main(int argc, char const *argv[]) +{ + if(argc == 1) { + return 1; + } + else { + const char *str[argc]; + for(int i = 0; i < argc; i++) { + str[i] = argv[i+1]; + } + reverse(str, 0, argc - 1); + printf("\n"); + } + return 0; +} diff --git a/Simple_Permutation b/Simple_Permutation new file mode 100644 index 00000000..206a9ced --- /dev/null +++ b/Simple_Permutation @@ -0,0 +1,9 @@ +//An optimized permutation code in Java +//initial values: +int x = 0; +int y = 1; +//cheap and fast swapping: +x = x ^ y; +y = x ^ y; +x = x ^ y; +//yields: x = 1 and y = 0 diff --git a/Singly Linklist.cpp b/Singly Linklist.cpp new file mode 100644 index 00000000..a4e30e8e --- /dev/null +++ b/Singly Linklist.cpp @@ -0,0 +1,36 @@ +#include +using namespace std; +struct nodes { + int data; + nodes* next; +}; +class LinkList { + private: + nodes* first; + public: + LinkList() { first = NULL; } + void AddData(int d); + void Display(); +}; +void LinkList::AddData(int d) { + nodes* newlink = new nodes; + newlink->data = d; + newlink->next = first; + first = newlink; +} +void LinkList::Display() { + nodes* current = first; + while(current != NULL) { + cout<data<next; + } +} +int main() { + LinkList l; + l.AddData(34); + l.AddData(45); + l.AddData(65); + l.AddData(66); + l.Display(); + return 0; +} diff --git a/Smiles b/Smiles new file mode 100644 index 00000000..41b197be --- /dev/null +++ b/Smiles @@ -0,0 +1,4 @@ +Nama: Abzuxz +About:Student +Place:Indonesia +Email: Abzuxz21@gmail.com diff --git a/Smiley_pattern.cpp b/Smiley_pattern.cpp new file mode 100644 index 00000000..962fbd93 --- /dev/null +++ b/Smiley_pattern.cpp @@ -0,0 +1,15 @@ +#include +#include +void main() +{ clrscr(); + int n; + cout<<"Enter the number of rows ="; + cin>>n; + char ch=1; + for(int i=0,i + +using namespace std; + +int main() { + long long int T; + cin >> T; // Reading input from STDIN + while(T--) { + long long int N, A, B; + cin>>N>>A>>B; + long long int x = (N*B)/(A+B); + long long int a1 = A*x*x + B*(N-x)*(N-x); + long long int a2 = A*(x+1)*(x+1) + B*(N-x-1)*(N-x-1); + if(a1q1", 2); + System.out.println(Password[2] + " It is! Now for the final Question: write your Name!"); + Password[3] = scan.next(); + Decode("You are truly the Hactober participant!", 1); + System.out.println("Hello World and Hello to you " + Password[3]); + } + + public static void Decode(String message, int time) + { + System.out.println(message); + try + { + TimeUnit.SECONDS.sleep(time); + } + catch (InterruptedException ex) + { + System.out.println("System Breach! Exiting..."); + System.exit(0); + } + } +} \ No newline at end of file diff --git a/a.py b/a.py new file mode 100644 index 00000000..459a9ae2 --- /dev/null +++ b/a.py @@ -0,0 +1 @@ +print "go have fun" \ No newline at end of file diff --git a/acronym_in_c/acronym.c b/acronym_in_c/acronym.c new file mode 100644 index 00000000..c109a210 --- /dev/null +++ b/acronym_in_c/acronym.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include "acronym.h" + +char *abbreviate(const char *phrase) +{ + size_t count = 0; + + + if (phrase == NULL) return NULL; + size_t length = strlen(phrase); + if (length == 0) return NULL; + + char * abbrev = malloc(sizeof(size_t)*14); + + abbrev[0] = toupper(phrase[0]); + + for ( const char * ptr = phrase; *ptr; ptr++) + { + if (*ptr == 32 || *ptr == 45) + { + count ++; + abbrev[count] = toupper(*(ptr + 1)); + } + } + + abbrev[count + 1] = '\0'; + return abbrev; +} diff --git a/acronym_in_c/acronym.h b/acronym_in_c/acronym.h new file mode 100644 index 00000000..02eaeea2 --- /dev/null +++ b/acronym_in_c/acronym.h @@ -0,0 +1,6 @@ +#ifndef ACRONYM_H +#define ACRONYM_H + +char *abbreviate(const char *phrase); + +#endif diff --git a/algo_IPS.cpp b/algo_IPS.cpp new file mode 100644 index 00000000..b37eda43 --- /dev/null +++ b/algo_IPS.cpp @@ -0,0 +1,33 @@ +#include + using namespace std; + + int main() + { + int dinda,tiwi,din,tiw,nda; + + tiw=0, tiwi=1, nda=0; + //Menghitung Indeks Prestasi Semester + cout<<"Indeks Prestasi Semester"< + + + + + + + +

CSS Arrows

+ +

Right arrow:

+ + + + diff --git a/bag/bag.java b/bag/bag.java new file mode 100644 index 00000000..32412a2c --- /dev/null +++ b/bag/bag.java @@ -0,0 +1,125 @@ +package bag.java; + +import java.util.Iterator; +import java.util.NoSuchElementException; + +/** + * Collection which does not allow removing elements (only collect and iterate) + * + * @param - the generic type of an element in this bag + */ +public class Bag implements Iterable { + + private Node firstElement; // first element of the bag + private int size; // size of bag + + private static class Node { + private Element content; + private Node nextElement; + } + + /** + * Create an empty bag + */ + public Bag() { + firstElement = null; + size = 0; + } + + /** + * @return true if this bag is empty, false otherwise + */ + public boolean isEmpty() { + return firstElement == null; + } + + /** + * @return the number of elements + */ + public int size() { + return size; + } + + /** + * @param element - the element to add + */ + public void add(Element element) { + Node oldfirst = firstElement; + firstElement = new Node<>(); + firstElement.content = element; + firstElement.nextElement = oldfirst; + size++; + } + + /** + * Checks if the bag contains a specific element + * + * @param element which you want to look for + * @return true if bag contains element, otherwise false + */ + public boolean contains(Element element) { + Iterator iterator = this.iterator(); + while(iterator.hasNext()) { + if (iterator.next().equals(element)) { + return true; + } + } + return false; + } + + /** + * @return an iterator that iterates over the elements in this bag in arbitrary order + */ + public Iterator iterator() { + return new ListIterator<>(firstElement); + } + + @SuppressWarnings("hiding") + private class ListIterator implements Iterator { + private Node currentElement; + + public ListIterator(Node firstElement) { + currentElement = firstElement; + } + + public boolean hasNext() { + return currentElement != null; + } + + /** + * remove is not allowed in a bag + */ + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + public Element next() { + if (!hasNext()) + throw new NoSuchElementException(); + Element element = currentElement.content; + currentElement = currentElement.nextElement; + return element; + } + } + + /** + * main-method for testing + */ + public static void main(String[] args) { + Bag bag = new Bag<>(); + + bag.add("1"); + bag.add("1"); + bag.add("2"); + + System.out.println("size of bag = " + bag.size()); + for (String s : bag) { + System.out.println(s); + } + + System.out.println(bag.contains(null)); + System.out.println(bag.contains("1")); + System.out.println(bag.contains("3")); + } +} diff --git a/basic_IO.py b/basic_IO.py new file mode 100644 index 00000000..95574bf9 --- /dev/null +++ b/basic_IO.py @@ -0,0 +1,17 @@ +#latihan 1# +#proses masukan dan keluaran# +print ("input nilai a dan b") +a = eval(input("Nilai a = ")) +b = eval(input("Nilai b = ")) + +#operasi perhitungan +h1=a+b +h2=a-b +h3=a*b +h4=a/b + +#cetak hasil +print ("Penjumlahan a dengan b = ",h1) +print ("Pengurangan a dengan b = ",h2) +print ("Perkalian a dengan b = ",h3) +print ("Pembagian a dengan b = ",h4) \ No newline at end of file diff --git a/binary_search/BinarySearch(Java).java b/binary_search/BinarySearch(Java).java new file mode 100644 index 00000000..f1db43ac --- /dev/null +++ b/binary_search/BinarySearch(Java).java @@ -0,0 +1,31 @@ +public class BinarySearch +{ + public static int bsearch(int arr[], int numb) +{ + int l = 0, r = arr.length - 1; + while(l <= r) +{ + int mid = (l + r) >> 1; + if (arr[mid] == numb) +{ + return mid; + } +else if(arr[mid] < numb) +{ + l = mid + 1; +} + else +{ + r = mid - 1; +} +} + return -1; +} + public static void main(String args[]) +{ + int arr[] = {100,200,300,400,500}; + int numb = 100; + int ans = bsearch(arr,val); + System.out.println((ans == -1) ? "Element not found" : "Element is found at index: " + ans); + } +} diff --git a/binary_search/bsearch.java b/binary_search/bsearch.java new file mode 100644 index 00000000..5db7c4c9 --- /dev/null +++ b/binary_search/bsearch.java @@ -0,0 +1,35 @@ +// Java program to demonstrate working of Collections. +// binarySearch() +import java.util.List; +import java.util.ArrayList; +import java.util.Collections; + +public class GFG +{ + public static void main(String[] args) + { + List al = new ArrayList(); + al.add(1); + al.add(2); + al.add(3); + al.add(10); + al.add(20); + + // 10 is present at index 3. + int key = 10; + int res = Collections.binarySearch(al, key); + if (res >= 0) + System.out.println(key + " found at index = " + + res); + else + System.out.println(key + " Not found"); + + key = 15; + res = Collections.binarySearch(al, key); + if (res >= 0) + System.out.println(key + " found at index = " + + res); + else + System.out.println(key + " Not found"); + } +} diff --git a/binomial_coefficient/BinomialCoefficient.py b/binomial_coefficient/BinomialCoefficient.py new file mode 100644 index 00000000..2232a202 --- /dev/null +++ b/binomial_coefficient/BinomialCoefficient.py @@ -0,0 +1,9 @@ +""" computing binomial coefficient """ +n = int(input("Enter the degree : ")) + +b = [[1 for j in range(i+1)] for i in range(n+1)] +for i in range(2,n+1): + for j in range(1,i): + b[i][j] = b[i-1][j] + b[i-1][j-1] + +print(b) \ No newline at end of file diff --git a/bitwisesieve.cpp b/bitwisesieve.cpp new file mode 100644 index 00000000..8f561813 --- /dev/null +++ b/bitwisesieve.cpp @@ -0,0 +1,91 @@ +#include +using namespace std; +#define mp make_pair +#define pb push_back +#define pii pair +#define __FAST ios_base::sync_with_stdio(0); cin.tie(0); +typedef long long ll; +typedef unsigned long long ull; + +pair arah[8] = { {0,1} , {1,1} , {1,0} , {1,-1} , {0,-1} , {-1,-1} , {-1,0} , {-1,1} }; + +bool cmp (int i,int j) { return (i>j); } + +const int ssize = int(1e8+3); +int prime[ssize/64]; + +// Checks whether x is prime or composite +bool ifnotPrime(int prime[], int x) +{ + // checking whether the value of element + // is set or not. Using prime[x/64], we find + // the slot in prime array. To find the bit + // number, we divide x by 2 and take its mod + // with 32. + return (prime[x/64] & (1 << ((x >> 1) & 31))); +} + +// Marks x composite in prime[] +bool makeComposite(int prime[], int x) +{ + // Set a bit corresponding to given element. + // Using prime[x/64], we find the slot in prime + // array. To find the bit number, we divide x + // by 2 and take its mod with 32. + prime[x/64] |= (1 << ((x >> 1) & 31)); +} + +// Prints all prime numbers smaller than n. +void bitWiseSieve(int n) +{ + // Assuming that n takes 32 bits, we reduce + // size to n/64 from n/2. + // Initializing values to 0 . + memset(prime, 0, sizeof(prime)); + + // 2 is the only even prime so we can ignore that + // loop starts from 3 as we have used in sieve of + // Eratosthenes . + for (int i = 3; i * i <= n; i += 2) { + + // If i is prime, mark all its multiples as + // composite + if (!ifnotPrime(prime, i)) + for (int j = i * i, k = i << 1; j < n; j += k) + makeComposite(prime, j); + } +} + +int main() +{ + bitWiseSieve(100000002); + int n,x; + scanf("%d", &n); + for (int i = 0; i < n; ++i) + { + scanf("%d", &x); + if (x==2 || (!ifnotPrime(prime, x) && x%2)) + { + + printf("0\n"); + } else { + int temp = x; + if (temp%2==0) + { + temp--; + } + while(1){ + if (ifnotPrime(prime, temp)) + { + temp-=2; + } else { + break; + } + + } + printf("%d\n", (x-temp)); + } + + } + return 0; +} \ No newline at end of file diff --git a/bubble_sort.cpp b/bubble_sort.cpp new file mode 100644 index 00000000..38a1386e --- /dev/null +++ b/bubble_sort.cpp @@ -0,0 +1,32 @@ + +#include + +using namespace std; + +int main() +{ + int a[50],n,i,j,temp; + cout<<"Enter the size of array: "; + cin>>n; + cout<<"Enter the array elements: "; + + for(i=0;i>a[i]; + + for(i=1;ia[j+1]) + { + temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + + cout<<"Array after bubble sort:"; + for(i=0;ialist[i+1]: + temp = alist[i] + alist[i] = alist[i+1] + alist[i+1] = temp + + print(alist) + +alist = [54,26,93,17,77,31,44,55,20] +bbSort(alist) + +print(Happy Hacktober!) \ No newline at end of file diff --git a/call-by-reference/call_by_referance.c b/call-by-reference/call_by_referance.c index db858520..f52667f9 100644 --- a/call-by-reference/call_by_referance.c +++ b/call-by-reference/call_by_referance.c @@ -1,11 +1,13 @@ #include -void increment(int *var) + +void increment(int *num) { - *var = *var+1; + *num = *num+1; } int main() { - int num=20; + float num; + scanf("%lf",&num); increment(&num); printf("Value of num is: %d", num); return 0; diff --git a/call-by-value/call_by_value.c b/call-by-value/call_by_value.c index 64361176..08cc6d3a 100644 --- a/call-by-value/call_by_value.c +++ b/call-by-value/call_by_value.c @@ -1,5 +1,4 @@ #include -#include int increment(int var) { var = var+1; diff --git a/call-by-value/callbyvalue.cpp b/call-by-value/callbyvalue.cpp index ee38f3ec..bba18ea8 100644 --- a/call-by-value/callbyvalue.cpp +++ b/call-by-value/callbyvalue.cpp @@ -7,7 +7,8 @@ int sum(int a, int b)//function declared } int main() { - int x, y; + int x=0, y=0, z=0; cin>>x>>y;//input x and y - cout<(s2+s3) or s2>(s1+s3) or s3>(s1+s2): + print('INVALID') +else: + print('valid') diff --git a/circular_linked_list.c b/circular_linked_list.c new file mode 100644 index 00000000..0b767be8 --- /dev/null +++ b/circular_linked_list.c @@ -0,0 +1,115 @@ +#include +#include +typedef struct node{ + int data; + struct node* next; +}node; +node* last=NULL; +void display(){ + node* r=last; + if(last==NULL) + printf("List is empty\n"); + else{ + /*do{ + r=r->next; + printf("%d ",r->data); + }while(r!=last);*/ + r=r->next; + while(r!=last){ + printf("%d ",r->data); + r=r->next; + } + printf("%d\n",r->data); + } +} +void insert(){ + int n,i; + node* r=NULL; + node* e=last; + node* t=NULL; + r=(node*)malloc(sizeof(node)); + printf("Enter the position where you want to insert the element: "); + scanf("%d",&n); + if((last==NULL)&&(n!=0)) + printf("Invalid\n"); + else if((last==NULL)&&(n==0)){ + printf("Enter data: "); + scanf("%d",&(r->data)); + last=r; + last->next=r; + } + else if ((n==0)&&(last!=NULL)){ + printf("Enter data: "); + scanf("%d",&(r->data)); + r->next=e->next; + e->next=r; + } + else{ + for(i=0;inext; + if (e->next==last) + { + break; + } + } + if (e->next==last){ + printf("Enter data: "); + scanf("%d",&(r->data)); + r->next=e->next; + e->next=r; + last=r; + } + else{ + printf("Enter data: "); + scanf("%d",&(r->data)); + t=e->next; + e->next=r; + r->next=t; + } + } +} +void delete(){ + int i,a; + node* r=last->next; + node* temp=last; + printf("Enter the entry you want to delete: "); + scanf("%d",&a); + while(r->next!=last){ + if (r->data==a){ + temp->next=r->next; + free(r); + } + else{ + temp=r; + r=r->next; + } + } + if (last->data==a){ + last=r; + r=r->next; + last->next=r->next; + free(r); + } + else + printf("Given entry is not in the list\n"); + +} +int main(){ + int n; + while(1){ + printf("1. Add a element to the list\n2. Remove a element from the list\n3. View list\n4. Exit\n"); + scanf("%d",&n); + switch(n){ + case 1: insert(); + break; + case 2: delete(); + break; + case 3: display(); + break; + case 4: exit (0); + break; + default: printf("Invalid"); + } + } + return 0; +} \ No newline at end of file diff --git a/counter.js b/counter.js new file mode 100644 index 00000000..438a9d66 --- /dev/null +++ b/counter.js @@ -0,0 +1,6 @@ +var counter = 0; + +setTimeout(function() { + counter = counter + 1; + console.log(counter); +}, 1000); diff --git a/crcrefined.java b/crcrefined.java new file mode 100644 index 00000000..015ba053 --- /dev/null +++ b/crcrefined.java @@ -0,0 +1,45 @@ +import java.util.*; +public class crcrefined { + int old,dataword,hpd,divisor,k; + public crcrefined() + { + hpd=16; divisor=0b10001000000100001000000000000000; + } + public void Divide() + { + for(int i=0; i<=16; i++) { //run loop hpd times + k = dataword; //k is remainder + if((k>>>31)==1) /*Check if first bit is 1*/ k = (k)^(divisor); //if bits match XOR + dataword = k; + dataword <<= 1; //to remove first bit after XOR + } + k>>=15; //lose leading 0's + System.out.println("k is " + Integer.toBinaryString(k)); + } + public static void main(String args[]) + { + Scanner sc = new Scanner(System.in); + crcrefined cr = new crcrefined(); + System.out.println("Enter Dataword"); + cr.dataword = sc.nextInt(); + System.out.println("DataWord is: "+Integer.toBinaryString(cr.dataword)); + cr.old=cr.dataword; + cr.dataword<<=15; + cr.Divide(); + int n = (cr.old<>=cr.hpd; + System.out.println("Data recieved: "+cr.old); + System.out.println("Binary encoded: "+Integer.toBinaryString(cr.old)); + } + else System.out.println("Data Corrupted!"); + sc.close(); + } +} \ No newline at end of file diff --git a/crypto/AES/AES.c b/crypto/AES/AES.c new file mode 100644 index 00000000..924a3793 --- /dev/null +++ b/crypto/AES/AES.c @@ -0,0 +1,144 @@ +#include +#include "AES.h" + +typedef unsigned char BYTE; +#define NUM_BYTE 128/8 + +BYTE SBOX[16][16] = { + 0x63,0x7C,0x77,0x7B,0xF2,0x6B,0x6F,0xC5,0x30,0x01,0x67,0x2B,0xFE,0xD7,0xAB,0x76, + 0xCA,0x82,0xC9,0x7D,0xFA,0x59,0x47,0xF0,0xAD,0xD4,0xA2,0xAF,0x9C,0xA4,0x72,0xC0, + 0xB7,0xFD,0x93,0x26,0x36,0x3F,0xF7,0xCC,0x34,0xA5,0xE5,0xF1,0x71,0xD8,0x31,0x15, + 0x04,0xC7,0x23,0xC3,0x18,0x96,0x05,0x9A,0x07,0x12,0x80,0xE2,0xEB,0x27,0xB2,0x75, + 0x09,0x83,0x2C,0x1A,0x1B,0x6E,0x5A,0xA0,0x52,0x3B,0xD6,0xB3,0x29,0xE3,0x2F,0x84, + 0x53,0xD1,0x00,0xED,0x20,0xFC,0xB1,0x5B,0x6A,0xCB,0xBE,0x39,0x4A,0x4C,0x58,0xCF, + 0xD0,0xEF,0xAA,0xFB,0x43,0x4D,0x33,0x85,0x45,0xF9,0x02,0x7F,0x50,0x3C,0x9F,0xA8, + 0x51,0xA3,0x40,0x8F,0x92,0x9D,0x38,0xF5,0xBC,0xB6,0xDA,0x21,0x10,0xFF,0xF3,0xD2, + 0xCD,0x0C,0x13,0xEC,0x5F,0x97,0x44,0x17,0xC4,0xA7,0x7E,0x3D,0x64,0x5D,0x19,0x73, + 0x60,0x81,0x4F,0xDC,0x22,0x2A,0x90,0x88,0x46,0xEE,0xB8,0x14,0xDE,0x5E,0x0B,0xDB, + 0xE0,0x32,0x3A,0x0A,0x49,0x06,0x24,0x5C,0xC2,0xD3,0xAC,0x62,0x91,0x95,0xE4,0x79, + 0xE7,0xC8,0x37,0x6D,0x8D,0xD5,0x4E,0xA9,0x6C,0x56,0xF4,0xEA,0x65,0x7A,0xAE,0x08, + 0xBA,0x78,0x25,0x2E,0x1C,0xA6,0xB4,0xC6,0xE8,0xDD,0x74,0x1F,0x4B,0xBD,0x8B,0x8A, + 0x70,0x3E,0xB5,0x66,0x48,0x03,0xF6,0x0E,0x61,0x35,0x57,0xB9,0x86,0xC1,0x1D,0x9E, + 0xE1,0xF8,0x98,0x11,0x69,0xD9,0x8E,0x94,0x9B,0x1E,0x87,0xE9,0xCE,0x55,0x28,0xDF, + 0x8C,0xA1,0x89,0x0D,0xBF,0xE6,0x42,0x68,0x41,0x99,0x2D,0x0F,0xB0,0x54,0xBB,0x16 +}; + +BYTE INV_SBOX[16][16] = { + 0x52,0x09,0x6A,0xD5,0x30,0x36,0xA5,0x38,0xBF,0x40,0xA3,0x9E,0x81,0xF3,0xD7,0xFB, + 0x7C,0xE3,0x39,0x82,0x9B,0x2F,0xFF,0x87,0x34,0x8E,0x43,0x44,0xC4,0xDE,0xE9,0xCB, + 0x54,0x7B,0x94,0x32,0xA6,0xC2,0x23,0x3D,0xEE,0x4C,0x95,0x0B,0x42,0xFA,0xC3,0x4E, + 0x08,0x2E,0xA1,0x66,0x28,0xD9,0x24,0xB2,0x76,0x5B,0xA2,0x49,0x6D,0x8B,0xD1,0x25, + 0x72,0xF8,0xF6,0x64,0x86,0x68,0x98,0x16,0xD4,0xA4,0x5C,0xCC,0x5D,0x65,0xB6,0x92, + 0x6C,0x70,0x48,0x50,0xFD,0xED,0xB9,0xDA,0x5E,0x15,0x46,0x57,0xA7,0x8D,0x9D,0x84, + 0x90,0xD8,0xAB,0x00,0x8C,0xBC,0xD3,0x0A,0xF7,0xE4,0x58,0x05,0xB8,0xB3,0x45,0x06, + 0xD0,0x2C,0x1E,0x8F,0xCA,0x3F,0x0F,0x02,0xC1,0xAF,0xBD,0x03,0x01,0x13,0x8A,0x6B, + 0x3A,0x91,0x11,0x41,0x4F,0x67,0xDC,0xEA,0x97,0xF2,0xCF,0xCE,0xF0,0xB4,0xE6,0x73, + 0x96,0xAC,0x74,0x22,0xE7,0xAD,0x35,0x85,0xE2,0xF9,0x37,0xE8,0x1C,0x75,0xDF,0x6E, + 0x47,0xF1,0x1A,0x71,0x1D,0x29,0xC5,0x89,0x6F,0xB7,0x62,0x0E,0xAA,0x18,0xBE,0x1B, + 0xFC,0x56,0x3E,0x4B,0xC6,0xD2,0x79,0x20,0x9A,0xDB,0xC0,0xFE,0x78,0xCD,0x5A,0xF4, + 0x1F,0xDD,0xA8,0x33,0x88,0x07,0xC7,0x31,0xB1,0x12,0x10,0x59,0x27,0x80,0xEC,0x5F, + 0x60,0x51,0x7F,0xA9,0x19,0xB5,0x4A,0x0D,0x2D,0xE5,0x7A,0x9F,0x93,0xC9,0x9C,0xEF, + 0xA0,0xE0,0x3B,0x4D,0xAE,0x2A,0xF5,0xB0,0xC8,0xEB,0xBB,0x3C,0x83,0x53,0x99,0x61, + 0x17,0x2B,0x04,0x7E,0xBA,0x77,0xD6,0x26,0xE1,0x69,0x14,0x63,0x55,0x21,0x0C,0x7D +}; + +void AddRoundKey(BYTE text[], BYTE key[]){ + for(unsigned int i = 0; i < NUM_BYTE; i++ ){ + text[i] ^= key[i]; + } +} + +void SubBytes(BYTE text[]){ + unsigned int index; + for(unsigned int i = 0; i < NUM_BYTE; i++ ){ + text[i] = SBOX[text[i] >>4][text[i] &0xF]; + } +} + +void ShiftRows(BYTE text[]){ + BYTE buffer [16]; + + buffer[0] = text[0]; + buffer[1] = text[5]; + buffer[2] = text[10]; + buffer[3] = text[15]; + buffer[4] = text[4]; + buffer[5] = text[9]; + buffer[6] = text[14]; + buffer[7] = text[3]; + buffer[8] = text[8]; + buffer[9] = text[13]; + buffer[10] = text[2]; + buffer[11] = text[7]; + buffer[12] = text[12]; + buffer[13] = text[1]; + buffer[14] = text[6]; + buffer[15] = text[11]; + + memcpy(text,buffer,NUM_BYTE); +} + +void MixColumns(BYTE text[]){ + + BYTE buffer[4]; + BYTE double_buffer[4]; + BYTE msb; + + for(int k = 0; k < NUM_BYTE; k+=4){ + for(int i = 0; i < 4; i++){ + buffer[i] = text[k+i]; + msb = (unsigned char)((signed char)text[k+i] >> 7); + double_buffer[i] = text[k+i] <<1; + double_buffer[i] ^= 0x1B & msb; + } + + text[k] = double_buffer[0] ^ buffer[3] ^ buffer[2] ^ buffer[1] ^ double_buffer[1]; + text[k+1] = double_buffer[1] ^ buffer[0] ^ buffer[3] ^ buffer[2] ^ double_buffer[2]; + text[k+2] = double_buffer[2] ^ buffer[1] ^ buffer[0] ^ buffer[3] ^ double_buffer[3]; + text[k+3] = double_buffer[3] ^ buffer[2] ^ buffer[1] ^ buffer[0] ^ double_buffer[0]; + } +} + +BYTE _rcon[11] = {0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b,0x36}; + +void newRoundKey(BYTE key[], int numRound){ + + BYTE buffer[4]; + BYTE tmp; + + memcpy(buffer,key+12,4); + tmp = buffer[0]; + for(unsigned int i =0 ; i<3; i++) + buffer[i] = buffer[i + 1]; + buffer[3] = tmp; + + for(unsigned int i = 0; i < 4; i++) + buffer[i] = SBOX[buffer[i] >>4][buffer[i] &0xF]; + + buffer[0] ^= _rcon[numRound]; + + for(int i = 0; i < 4; i++) + key[i] ^= buffer[i]; + + for(unsigned int i = 0; i < 12; i++) + key[i+4] ^= key[i]; +} + +void aes128_encrypt(unsigned char input[], unsigned char output[], unsigned char key[]){ + BYTE bufferKey [16]; + memcpy(bufferKey, key, 16); + memcpy(output, input, 16); + + AddRoundKey(output,bufferKey); + for(int i = 1; i< 10;i++){ + SubBytes(output); + ShiftRows(output); + MixColumns(output); + newRoundKey(bufferKey,i); + AddRoundKey(output,bufferKey); + } + SubBytes(output); + ShiftRows(output); + newRoundKey(bufferKey,10); + AddRoundKey(output,bufferKey); +} diff --git a/crypto/AES/AES.h b/crypto/AES/AES.h new file mode 100644 index 00000000..73113bd2 --- /dev/null +++ b/crypto/AES/AES.h @@ -0,0 +1,6 @@ +#ifndef AES_H +#define AES_H + +void aes128_encrypt(unsigned char input[], unsigned char output[], unsigned char key[]); + +#endif diff --git a/css/arrow.html b/css/arrow.html index 3c80d0dd..ab445ce0 100644 --- a/css/arrow.html +++ b/css/arrow.html @@ -4,6 +4,7 @@ + Arrow

Arrow

@@ -12,4 +13,4 @@

Arrow

- \ No newline at end of file + diff --git a/css/basic.html b/css/basic.html index 0f41050c..4940da49 100644 --- a/css/basic.html +++ b/css/basic.html @@ -12,23 +12,26 @@ + - -

- Welcome To My Landing Page. -

- - - - - +
+

+ Welcome To My Landing Page. +

+
+ + diff --git a/css/css-arrow-sl.html b/css/css-arrow-sl.html new file mode 100644 index 00000000..11902f21 --- /dev/null +++ b/css/css-arrow-sl.html @@ -0,0 +1,39 @@ + + + + + + CSS Arrow + + +
+
+ + \ No newline at end of file diff --git a/css/css__arrow.html b/css/css__arrow.html new file mode 100644 index 00000000..f1b3eb0b --- /dev/null +++ b/css/css__arrow.html @@ -0,0 +1,21 @@ + + + + Css Arrow + + + + +
+ +
+ + + \ No newline at end of file diff --git a/css/styles.css b/css/styles.css index b291708f..ceb7e5a1 100644 --- a/css/styles.css +++ b/css/styles.css @@ -1,36 +1,58 @@ @charset "UTF-8"; h1 { - text-align:center; - font-size:2vw; - font-family: Arial, Helvetica, sans-serif; - + text-align : center; + font-size : 200%; + font-family : Arial, Helvetica, serif; + text-decoration : underline; + color : darkcyan; } ul { - list-style-type: none; - background-color:#333333; - padding:0; - margin:0; - overflow:hidden; + list-style-type : none; + background-color : #333; + padding : 0; + margin : 0; + overflow : hidden; } -li { - float:left; - } + li a { - text-decoration: none; - display:block; - padding:18px; - color:white; - text-align: center; - + text-decoration : none; + display : block; + padding : 18px; + color : #FFF; + text-align : center; } -li a:hover{ - background-color:#111111; +nav ul li a:hover{ + background-color : rgba(255,255,255,30%); + color : brown; } + body { - background-image:url(landing.jpeg); + background-image : url(landing.jpeg); + font-family : titilium web,calbri,serif; + color : aliceblue; + + } + +.NavigationBar{ + width : 100%; + padding : 0 ; + background-size : cover; + text-align-last : center; + font-size : 20px; +} + +nav ul{ + width : 300px; + margin : 0 auto; + background-color : rgba(0,0,0,20%); + text-align : center; + border-radius : 50px; +} + + diff --git a/doubly_linked_list.c b/doubly_linked_list.c new file mode 100644 index 00000000..3059d473 --- /dev/null +++ b/doubly_linked_list.c @@ -0,0 +1,127 @@ +#include +#include +typedef struct node{ + int data; + struct node* next; + struct node* prev; +}node; +node* start=NULL; +void insert(){ + int i,m; + node* t=NULL; + t=(node*)malloc(sizeof(node)); + node* r=start; + printf("Enter the position where you want to add the element: "); + scanf("%d",&m); + if ((start==NULL)&&(m!=0)){ + printf("Invalid"); + } + else if ((start==NULL)&&(m==0)){ + printf("Enter data: "); + scanf("%d",&(t->data)); + start=t; + start->next=NULL; + start->prev=NULL; + } + else{ + for (i = 0; i < m; i++){ + if (r->next==NULL){ + break; + } + r=r->next; + } + if(r->next==NULL){ + printf("Enter data: "); + scanf("%d",&(t->data)); + r->next=t; + t->prev=r; + } + else{ + printf("Enter data: "); + scanf("%d",&(t->data)); + t->next=r->next; + ((r->next)->prev)=t; + r->next=t; + t->prev=r; + } + } +} +void delete(){ + int i,m; + node* r=start; + printf("Enter the position from where you want to delete the element: "); + scanf("%d",&m); + if((start==NULL)&&(m!=0)){ + printf("List is empty\n"); + } + else if((start!=NULL)&&(m==0)){ + start=start->next; + start->prev=NULL; + free(r); + } + else{ + for (i = 0; i < m; i++){ + if (r->next==NULL) + break; + r=r->next; + } + if (r->next==NULL){ + ((r->prev)->next)=NULL; + free(r); + } + else{ + ((r->prev)->next)=r->next; + ((r->next)->prev)=r->prev; + free(r); + } + } +} +void forward(){ + node* r=start; + while(r->next!=NULL){ + printf("%d ",r->data); + r=r->next; + } + printf("%d ",r->data); +} +void backward(){ + node* r=start; + while(r->next!=NULL){ + r=r->next; + } + while(r->prev!=NULL){ + printf("%d ",r->data); + r=r->prev; + } + printf("%d ",r->data); +} +void display(){ + int m; + printf("1. forward order of list\n2. Backward order of list\n"); + scanf("%d",&m); + switch(m){ + case 1: forward(); + break; + case 2: backward(); + break; + default: printf("invalid\n"); + } +} +void main(){ + int n; + while(1){ + printf("1. Add a number to the list\n2. Delete a number from the list\n3. View list\n4. Exit\n"); + scanf("%d",&n); + switch(n){ + case 1: insert(); + break; + case 2: delete(); + break; + case 3: display(); + break; + case 4: exit(0); + break; + default : printf("invalid"); + } + } +} \ No newline at end of file diff --git a/fact.py b/fact.py new file mode 100644 index 00000000..d973791b --- /dev/null +++ b/fact.py @@ -0,0 +1,7 @@ +def fact(n): + if n==1: + return 1 + return n*fact(n-1) + +n=int(input("Enter number: ")) +print("factorial is: ",fact(n)) \ No newline at end of file diff --git a/factorial.c b/factorial.c new file mode 100644 index 00000000..78f83395 --- /dev/null +++ b/factorial.c @@ -0,0 +1,13 @@ +#include +int main(){ + int num; + int i; + int factorial=1; + printf("Enter the number: "); + scanf("%d",&num); + for (i = 1; i <= num; i++){ + factorial=factorial*i; + } + printf("Factorial of %d is %d",num,factorial); + return 0; + } diff --git a/factorial.cpp b/factorial.cpp new file mode 100644 index 00000000..4c1e6215 --- /dev/null +++ b/factorial.cpp @@ -0,0 +1,20 @@ +//Basic Example for Direct Recursion.(Factorial of Number) +#include +#define ll long long +using namespace std; + +ll fact(int n) +{ + if (n < = 1) // base case + return 1; + else + return n*fact(n-1); +} + +int main() +{ + int n; + cout<<"Enter the Number?\n"; + cin>>n; + cout<<"Factorial of n is:"< - using namespace std; -long int factorial(int n) +long long int factorial(int n) { if(n==0) - return 1; + return 1; return n*factorial(n-1); } diff --git a/factorial/Myfactorial.c b/factorial/Myfactorial.c new file mode 100644 index 00000000..3770a511 --- /dev/null +++ b/factorial/Myfactorial.c @@ -0,0 +1,20 @@ +#include +int main() +{ + int c,num,fact=1; + printf("Enter a number:"); + scanf("%d",&num); + + for(c=1;c<=num;c++) + { + fact=fact*c; + + } + printf("Factorial od %d is:%d",num,fact); + +return 0; +} + + + +} \ No newline at end of file diff --git a/factorial/fact.c b/factorial/fact.c new file mode 100644 index 00000000..d4b96fb9 --- /dev/null +++ b/factorial/fact.c @@ -0,0 +1,15 @@ +#include + + +void main() +{ + int a; + scanf("%d", &a); + int res = 1; + + while(a) + {res*=a; + a--;} + + printf("%d\a", res); +} diff --git a/factorial/factorial.cpp b/factorial/factorial.cpp index ef050873..889ee344 100644 --- a/factorial/factorial.cpp +++ b/factorial/factorial.cpp @@ -1,24 +1,13 @@ -#include // Imports Standard Library "iostream" which is used for input and output - -using namespace std; // Removes the need for using std:: - -int factorial (int n) // Defining a function factiorial which takes an integer as an argument and returns an integer -{ - if(n==1) - { - return 1; - } - return n*factorial(n-1); // Recursive Function which calls itself with an argument with integer one less in value until it reaches one - -} -int main() -{ - int n,result; - cout<<"Enter the number whose factorial you want to find: "; - cin>>n;//Takes input for the value n - result=factorial(n); //Calls factorial with argument n and assigns its return value to result - cout<<"The result is \n"; - cout< +using namespace std; +int main() +{ + int i,fact=1,number; + cout<<"Enter any Number: "; + cin>>number; + for(i=1;i<=number;i++){ + fact=fact*i; + } + cout<<"Factorial of " < 0 do + n * of(n - 1) + end +end diff --git a/factorial/factorial.rs b/factorial/factorial.rs new file mode 100644 index 00000000..9a16ed93 --- /dev/null +++ b/factorial/factorial.rs @@ -0,0 +1,13 @@ +fn factorial_recursive (n: u64) -> u64 { + match n { + 0 => 1, + _ => n * factorial_recursive(n-1) + } +} + + +fn main () { + for i in 1..10 { + println!("{}", factorial_recursive(i)) + } +} diff --git a/factorial/factorial_c b/factorial/factorial_c new file mode 100644 index 00000000..80c4e887 --- /dev/null +++ b/factorial/factorial_c @@ -0,0 +1,24 @@ +#include +int main() +{ + int n, i; + unsigned long long factorial = 1; + + printf("Enter an integer: "); + scanf("%d",&n); + + // show error if the user enters a negative integer + if (n < 0) + printf("Error! Factorial of a negative number doesn't exist."); + + else + { + for(i=1; i<=n; ++i) + { + factorial *= i; // factorial = factorial*i; + } + printf("Factorial of %d = %llu", n, factorial); + } + + return 0; +} diff --git a/factorial/factorial_recursive.js b/factorial/factorial_recursive.js new file mode 100644 index 00000000..70308c23 --- /dev/null +++ b/factorial/factorial_recursive.js @@ -0,0 +1,17 @@ +const factorial = num => { + if (!Number.isInteger(num)) { + throw Error('Not an integer') + } + + if (num < 0) { + throw Error('Negative number') + } + + if (num == 0 || num == 1) { + return 1 + } + + return num * factorial(num-1); +} + +console.log(factorial(5)) diff --git a/factorial1.cpp b/factorial1.cpp new file mode 100644 index 00000000..bc6bfde4 --- /dev/null +++ b/factorial1.cpp @@ -0,0 +1,14 @@ +#include +using namespace std; +int main() +{ + int num,fact=1; + cout<<" Enter the no: for which you want the factorial"; + cin>>num; + for (int i=1;i<=num;i++) + { + fact=fact*i; + } + cout<<"Factorial of Given Number is ="<= 0: + # Check for number=0 case + if number == 0: + print(f'The factorial of {initial_number} is 1.') + # For all other cases + else: + # Loop to calculate factorial + while number > 1: + factorial = factorial * (number - 1) + number = number - 1 + print(f'The factorial of {initial_number} is {factorial}.') +else: + print('You did not enter a natural number, please try again!') diff --git a/factusingternary.cpp b/factusingternary.cpp new file mode 100644 index 00000000..10e81383 --- /dev/null +++ b/factusingternary.cpp @@ -0,0 +1,15 @@ +#include + +int factorial(int n) +{ + // single line to find factorial + return (n==1 || n==0) ? 1: n * factorial(n - 1); +} + +// Driver Code +int main() +{ + int num = 5; + printf ("Factorial of %d is %d", num, factorial(num)); + return 0; +} diff --git a/faktorial.cpp b/faktorial.cpp new file mode 100644 index 00000000..43de905b --- /dev/null +++ b/faktorial.cpp @@ -0,0 +1,21 @@ +//factorial using recursion +#include +using namespace std; +int factorial(int); + +int main() +{ + int n; + cin >> n; + cout << "Factorial of the entered no. is :" << factorial(n); +} + +int factorial(int n) +{ + if (n==0) { + return 1; + } + + return n * factorial(n-1); +} + diff --git a/fibonacci/fib_dp.cpp b/fibonacci/fib_dp.cpp new file mode 100644 index 00000000..046f5858 --- /dev/null +++ b/fibonacci/fib_dp.cpp @@ -0,0 +1,28 @@ +//Siddharth Jain +#include +using namespace std; +int memo[1000]; +int fib(int n) +{ + int ans ; + if(n==0)return 0; + if(n==1)return 1; + if(memo[n]!=-1) + { + return memo[n]; + } + ans=fib(n-1)+fib(n-2); + memo[n]=ans; + return ans; +} +int main() +{ + int n; + cin>>n; + for(int i=0;i<=n;i++) + {memo[i]=-1; + } + int ans =fib(n); + cout< 1; +fib(N) -> fib(N, 2, 1, 1). + +fib(N, Cur, An_1, An_2) when N =:= Cur -> An_2; +fib(N, Cur, An_1, An_2) -> fib(N, Cur + 1, An_2, An_1 + An_2). \ No newline at end of file diff --git a/fibonacci/fibonacci.sml b/fibonacci/fibonacci.sml new file mode 100644 index 00000000..97157141 --- /dev/null +++ b/fibonacci/fibonacci.sml @@ -0,0 +1,8 @@ +fun fibonacci 0 = 0 +| fibonacci 1 = 1 +| fibonacci n = fibonacci(n-1) + fibonacci(n-2); + +fibonacci 0; +fibonacci 1; +fibonacci 2; +fibonacci 3; \ No newline at end of file diff --git a/fibonacci/fibonacci_java b/fibonacci/fibonacci_java new file mode 100644 index 00000000..6ed93cff --- /dev/null +++ b/fibonacci/fibonacci_java @@ -0,0 +1,15 @@ +class Fibonacci{ +public static void main(String args[]) +{ + int n1=0,n2=1,n3,i,count=10; + System.out.print(n1+" "+n2); //printing 0 and 1 + + for(i=2;i +#include +#include + +using namespace std; + +/* +** Given a strictly increasing array A of positive integers forming a sequence, +** find the length of the longest fibonacci-like subsequence of A. +** If one does not exist, return 0. +*/ + +int lenLongestFibSubseq(vector& A) { + int N = (int) A.size(); + unordered_map index; + for (int i = 0; i < N; ++i) + index[A[i]] = i; + + unordered_map longest; + int ans = 0; + for (int k = 0; k < N; ++k) + for (int j = 0; j < k; ++j) { + if (A[k] - A[j] < A[j] && index.count(A[k] - A[j])) { + int i = index[A[k] - A[j]]; + longest[j * N + k] = longest[i * N + j] + 1; + ans = max(ans, longest[j * N + k] + 2); + } + } + + return ans >= 3 ? ans : 0; +} + +int main(int argc, const char * argv[]) { + vector v = {1,3,7,11,12,14,18,25}; + cout << lenLongestFibSubseq(v) << endl; + + return 0; +} diff --git a/fibonacci/rahul-fibonacci.cpp b/fibonacci/rahul-fibonacci.cpp new file mode 100644 index 00000000..8ec09538 --- /dev/null +++ b/fibonacci/rahul-fibonacci.cpp @@ -0,0 +1,27 @@ +//import libraries +#include + +using namespace std; +//call fibonacci function +int fibo(int); +//************************ +int main() +{ + cout<<"Enter a number: "; + int a; + cin>>a; + for(int i=0;i + +/* fold: breaks long lines of input into two or more lines at blank-space characters + * after the n-th column of input */ + +main() +{ + int c; + int column = 0; + + while ((c = getchar()) != EOF){ + if ((c == ' ' || c == '\t') && column >= 9){ + putchar('\n'); + c = 0; + column = 0; + } + putchar(c); + ++column; + } +} diff --git a/gcd.py b/gcd.py new file mode 100644 index 00000000..62e52d2e --- /dev/null +++ b/gcd.py @@ -0,0 +1,7 @@ +def computeHCF(x, y): + + # This function implements the Euclidian algorithm to find H.C.F. of two numbers + while(y): + x, y = y, x % y + + return x diff --git a/guessing game/guessing-game-node.js b/guessing game/guessing-game-node.js new file mode 100644 index 00000000..c71f4f27 --- /dev/null +++ b/guessing game/guessing-game-node.js @@ -0,0 +1,46 @@ +/*\ +|*| NodeJS Guessing Game Code +|*| @author William Zhou (https://github.com/wzhouwzhou) +\*/ + +const { createInterface } = require('readline'); + +const rl = createInterface({ + input: process.stdin, + output: process.stdout, +}); + +let meta; + +const validate = _input => { + const input = `${_input}`.trim(); + if (input === 'STOP') meta.signal = true; + if (meta.signal) { + rl.removeListener('line', validate); + console.log(meta.thankyou); + process.exit(0); + } + const num = parseInt(+input); + if (isNaN(num)) return console.log(meta.instructions); + if (num === meta.current_num) { + console.log(meta.correct()); + meta.counter = 0; + return meta.gen_guess(); + } else { + ++meta.counter; + console.log(meta.incorrect(num, meta.current_num)); + } +}; + +rl.on('line', validate); + +(meta = { + instructions: 'Please type a number, or "STOP" to quit.', + correct: () => `You guessed it in ${meta.counter} tries! A new number has been generated. ${meta.instructions}`, + incorrect: (num, answer) => `Your guess was too ${num > answer ? 'high' : 'low'}`, + signal: false, + counter: 1, + gen_guess: () => meta.current_num = ~~(100 * Math.random()), + start: () => (meta.gen_guess(), console.log(meta.instructions)), + thankyou: 'Thank you for playing! Brought to you by William Zhou (https://github.com/wzhouwzhou).' +}).start(); diff --git a/guessing game/guessing.cs b/guessing game/guessing.cs new file mode 100644 index 00000000..e2d55c1c --- /dev/null +++ b/guessing game/guessing.cs @@ -0,0 +1,12 @@ +void Main() +{ + int randint = new Random().Next(0,10); + while(true) + { + int guessed = Convert.ToInt32(Console.ReadLine()); + if(guessed==randint) + break; + Console.WriteLine( guessed>randint? "Value too big!" : "Value too low!" ); + } + Console.WriteLine($"Congratulations :D {randint} was the number."); +} diff --git a/heapsort.cpp b/heapsort.cpp new file mode 100644 index 00000000..6c45d8af --- /dev/null +++ b/heapsort.cpp @@ -0,0 +1,60 @@ +#include +using namespace std; +void MaxHeapify(int a[], int i, int n) +{ + int j, temp; + temp = a[i]; + j = 2*i; + + while (j <= n) + { + if (j < n && a[j+1] > a[j]) + j = j+1; + if (temp > a[j]) + break; + else if (temp <= a[j]) + { + a[j/2] = a[j]; + j = 2*j; + } + } + a[j/2] = temp; + return; +} +void HeapSort(int a[], int n) +{ + int i, temp; + for (i = n; i >= 2; i--) + { + temp = a[i]; + a[i] = a[1]; + a[1] = temp; + MaxHeapify(a, 1, i - 1); + } +} +void Build_MaxHeap(int a[], int n) +{ + int i; + for(i = n/2; i >= 1; i--) + MaxHeapify(a, i, n); +} +int main() +{ + int n, i; + cout<<"\nEnter the number of data element to be sorted: "; + cin>>n; + n++; + int arr[n]; + for(i = 1; i < n; i++) + { + cout<<"Enter element "<>arr[i];} + Build_MaxHeap(arr, n-1); + HeapSort(arr, n-1); + cout<<"\nSorted Data "; + + for (i = 1; i < n; i++) + cout<<"->"<= 0; i--) + heapify(arr, unsortedArray, i); + + for (int i = unsortedArray-1; i >= 0; i--) + { + int temp = arr[0]; + arr[0] = arr[i]; + arr[i] = temp; + + heapify(arr, i, 0); + } + } + + void heapify(int arr[], int n, int i) + { + int largest = i; + int left = 2*i + 1; + int right = 2*i + 2; + + if (left < n && arr[left] > arr[largest]) + largest = left; + + if (right < n && arr[right] > arr[largest]) + largest = right; + + if (largest != i) + { + int swap = arr[i]; + arr[i] = arr[largest]; + arr[largest] = swap; + + heapify(arr, n, largest); + } + } + + static void printArray(int arr[]) + { + int unsortedArray = arr.length; + for (int i = 0; i < unsortedArray; i++) { + System.out.print(arr[i] + " "); + } + } + + public static void main(String args[]) + { + int arr[] = {12, 15, 13, 5, 14, 11, 6, 7, 1, 8, 4}; + + HeapSort ob = new HeapSort(); + ob.sort(arr); + + System.out.println("The array got heap sorted:"); + printArray(arr); + } +} diff --git a/hello-world/Ashu-HelloWorld.py b/hello-world/Ashu-HelloWorld.py new file mode 100644 index 00000000..8cde7829 --- /dev/null +++ b/hello-world/Ashu-HelloWorld.py @@ -0,0 +1 @@ +print("hello world") diff --git a/hello-world/C-Hello_with_For.c b/hello-world/C-Hello_with_For.c index d42e9487..803a7f74 100644 --- a/hello-world/C-Hello_with_For.c +++ b/hello-world/C-Hello_with_For.c @@ -1,12 +1,11 @@ #include int main() { - char hello[13]="Hello, World!"; + char hello[13]="Hello World!"; for (int i = 0; i < 14; ++i) { printf("%c", hello[i]); } printf("\n"); - return 0; } diff --git a/hello-world/Hello-World.sh b/hello-world/Hello-World.sh new file mode 100644 index 00000000..eade7e5b --- /dev/null +++ b/hello-world/Hello-World.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# This is a comment! +echo "Hello World!" # This is a comment, too! diff --git a/hello-world/HelloHacktoberfest.java b/hello-world/HelloHacktoberfest.java new file mode 100644 index 00000000..39e8564b --- /dev/null +++ b/hello-world/HelloHacktoberfest.java @@ -0,0 +1,17 @@ +public class HelloHacktoberfest{ + + public static void main(String []args){ + int thisYear = 2018; + int previousYear = 2017; + System.out.println("Hello Hacktoberfest "+returnBiggerInt(thisYear,previousYear)); + } + + public static int returnBiggerInt(int a , int b) + { + if(a>b) + { + return a; + } + return b; + } +} \ No newline at end of file diff --git a/hello-world/HelloWorld.c b/hello-world/HelloWorld.c index 3b7617c2..6281daa8 100644 --- a/hello-world/HelloWorld.c +++ b/hello-world/HelloWorld.c @@ -1,6 +1,15 @@ #include -int main() -{ - printf("Hello, World!"); - return 0; + +void main(){ + printf("Hello World"); // prints Hello World to screen. } + + +// Uncomment lines below to practice printing to screen + +/* +void main() { + printf("This is a test to print to the screen"); + printf('Hello World'); +} +*/ diff --git a/hello-world/HelloWorld.py b/hello-world/HelloWorld.py index afbab225..c25b8a32 100644 --- a/hello-world/HelloWorld.py +++ b/hello-world/HelloWorld.py @@ -1,15 +1,2 @@ -l = [] -l.append("H") -l.append("e") -l.append("l") -l.append("l") -l.append("o") -l.append(" ") -l.append("w") -l.append("o") -l.append("r") -l.append("l") -l.append("d") - -for el in l: - print (el) \ No newline at end of file +#Script to print Hello World in Python! +print("Hello World") \ No newline at end of file diff --git a/hello-world/HelloWorldZippo.py b/hello-world/HelloWorldZippo.py new file mode 100644 index 00000000..3350f904 --- /dev/null +++ b/hello-world/HelloWorldZippo.py @@ -0,0 +1 @@ +print("Hello world, and hello Hacktoberfest.") diff --git a/hello-world/Helloworld.LOLCODE b/hello-world/Helloworld.LOLCODE new file mode 100644 index 00000000..c9715687 --- /dev/null +++ b/hello-world/Helloworld.LOLCODE @@ -0,0 +1,4 @@ +HAI +CAN HAS STDIO? +VISIBLE "HAI WORLD!" +KTHXBYE \ No newline at end of file diff --git a/hello-world/Helloworld.bal b/hello-world/Helloworld.bal new file mode 100644 index 00000000..d818da95 --- /dev/null +++ b/hello-world/Helloworld.bal @@ -0,0 +1,23 @@ +import ballerina/http; + +@http:ServiceConfig { + basePath: "/" +} + +//Bind a new service for port 9000 +service hello bind {port:9000} { + +//Only accept POST requests + @http:ResourceConfig { + path: "/", + methods: ["POST"] + } + //New resource named hello + hello (endpoint caller, http:Request request) { + + http:Response res; + res.setPayload("Hello World from Ballerina!"); + + _ = caller->respond(res); + } +} diff --git a/hello-world/Helloworld.brainfuck b/hello-world/Helloworld.brainfuck new file mode 100644 index 00000000..e0a83816 --- /dev/null +++ b/hello-world/Helloworld.brainfuck @@ -0,0 +1 @@ +++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>. \ No newline at end of file diff --git a/hello-world/Helloworld.foo b/hello-world/Helloworld.foo new file mode 100644 index 00000000..4f68d564 --- /dev/null +++ b/hello-world/Helloworld.foo @@ -0,0 +1 @@ +"Hello, World!" \ No newline at end of file diff --git a/hello-world/Helloworld.gridscript b/hello-world/Helloworld.gridscript new file mode 100644 index 00000000..86564263 --- /dev/null +++ b/hello-world/Helloworld.gridscript @@ -0,0 +1,7 @@ +#HELLO WORLD. + +@width 3 +@height 1 + +(1,1):START +(3,1):PRINT 'Hello World' \ No newline at end of file diff --git a/hello-world/Vishesh-helloWOrld.py b/hello-world/Vishesh-helloWOrld.py new file mode 100644 index 00000000..ebc95fa0 --- /dev/null +++ b/hello-world/Vishesh-helloWOrld.py @@ -0,0 +1,3 @@ +n=int(input("enter the times")) +for i in range(n): + print("hello world") diff --git a/hello-world/c#.cs b/hello-world/c#.cs index f3572444..e7cea0bb 100644 --- a/hello-world/c#.cs +++ b/hello-world/c#.cs @@ -1,7 +1,7 @@ using System; class Program { - public static void Main(string[] args) + public static void main(string[] args) { Console.WriteLine("Hello, world!"); } diff --git a/hello-world/hell-world-shark.rb b/hello-world/hell-world-shark.rb new file mode 100644 index 00000000..513f0d0c --- /dev/null +++ b/hello-world/hell-world-shark.rb @@ -0,0 +1,6 @@ +greeting = "Hello, World!" +location = "South Florida" +shark = "🦈" + +puts "#{greeting.upcase()} Greetings from #{location}" +puts "Here is a #{shark}" \ No newline at end of file diff --git a/hello-world/hello-world.sol b/hello-world/hello-world.sol new file mode 100644 index 00000000..303d5be5 --- /dev/null +++ b/hello-world/hello-world.sol @@ -0,0 +1,8 @@ +pragma solidity ^0.4.25; + +contract hello{ + string public say = "hello world"; + constructor() public{ + say; + } +} \ No newline at end of file diff --git a/hello-world/helloWorld.html b/hello-world/helloWorld.html index 193d371c..1416a70f 100644 --- a/hello-world/helloWorld.html +++ b/hello-world/helloWorld.html @@ -1,13 +1,10 @@ - - - - - - - Hello World! - - -

Hello World!

- This is my first program.
- + + + + Hello World web page + + + +

Hello World!

+ diff --git a/hello-world/helloWorld.py b/hello-world/helloWorld.py new file mode 100644 index 00000000..bf83dcad --- /dev/null +++ b/hello-world/helloWorld.py @@ -0,0 +1,5 @@ +def main(): + print("Hello World! =)") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/hello-world/helloWorldFromFrance.js b/hello-world/helloWorldFromFrance.js new file mode 100644 index 00000000..607d0eea --- /dev/null +++ b/hello-world/helloWorldFromFrance.js @@ -0,0 +1 @@ +alert("Salut la Terre et les Terreux !"); diff --git a/hello-world/hello_from_vietnam.cpp b/hello-world/hello_from_vietnam.cpp new file mode 100644 index 00000000..468c0e1e --- /dev/null +++ b/hello-world/hello_from_vietnam.cpp @@ -0,0 +1,5 @@ +#include +int main(){ + std::cout<<"hello world"<<'\n'; + exit(EXIT_SUCCESS); +} diff --git a/hello-world/hello_world.pb b/hello-world/hello_world.pb new file mode 100644 index 00000000..71ad4e76 --- /dev/null +++ b/hello-world/hello_world.pb @@ -0,0 +1 @@ +MessageRequester("Nachricht", "Hallo Welt!") diff --git a/hello-world/hello_world_by_dimali.c b/hello-world/hello_world_by_dimali.c new file mode 100644 index 00000000..c76cbd28 --- /dev/null +++ b/hello-world/hello_world_by_dimali.c @@ -0,0 +1,8 @@ +#include +//language:C + +int main() +{ + printf("Hello world!\n"); + +} diff --git a/hello-world/hello_world_jmig5776.CPP b/hello-world/hello_world_jmig5776.CPP new file mode 100644 index 00000000..64b215d3 --- /dev/null +++ b/hello-world/hello_world_jmig5776.CPP @@ -0,0 +1,11 @@ +//Importing Standard Library iostream - required for input and output +#include + +//Removes the need to use std:: +using namespace std; + +int main() +{ + cout << "Hello world!"< +using namespace std; +int main(){ + cout << "Hello HACKTOBERFEST" << endl; + return 0; +} diff --git a/hello-world/hellouditi.py b/hello-world/hellouditi.py new file mode 100644 index 00000000..e793b6dc --- /dev/null +++ b/hello-world/hellouditi.py @@ -0,0 +1 @@ +print ("hello world") diff --git a/hello-world/hellowithjs.js b/hello-world/hellowithjs.js new file mode 100644 index 00000000..93cb43ab --- /dev/null +++ b/hello-world/hellowithjs.js @@ -0,0 +1 @@ +console.log("Hello everyone, welcome to the hacktoberfest! ;)"); \ No newline at end of file diff --git a/hello-world/helloworld.groovy b/hello-world/helloworld.groovy new file mode 100644 index 00000000..ba4d39b0 --- /dev/null +++ b/hello-world/helloworld.groovy @@ -0,0 +1 @@ +println 'Hello World!' diff --git a/hello-world/helloworld.kt b/hello-world/helloworld.kt new file mode 100644 index 00000000..ff84744f --- /dev/null +++ b/hello-world/helloworld.kt @@ -0,0 +1,3 @@ +fun main(vararg args: String){ + println("Hello World!") +} diff --git a/hello-world/hola_mundo.asm b/hello-world/hola_mundo.asm new file mode 100644 index 00000000..b6d9a544 --- /dev/null +++ b/hello-world/hola_mundo.asm @@ -0,0 +1,23 @@ + +.model small +.stack +.data + saludo db "Hola mundo!!!", "$" + +.code + +main proc ;Inicia proceso + mov ax,seg saludo ;hmm ¿seg? + mov ds,ax ;ds = ax = saludo + + mov ah,09 ;Function(print string) + lea dx,saludo ;DX = String terminated by "$" + int 21h ;Interruptions DOS Functions + +;mensaje en pantalla + + mov ax,4c00h ;Function (Quit with exit code (EXIT)) + int 21h ;Interruption DOS Functions + +main endp ;Termina proceso +end main diff --git a/hello-world/ilhamhello.html b/hello-world/ilhamhello.html new file mode 100644 index 00000000..3e75661a --- /dev/null +++ b/hello-world/ilhamhello.html @@ -0,0 +1,10 @@ + + + + + Hello Ilham + + +

Helloo world! Welcome to Hacktoberfest!

+ + \ No newline at end of file diff --git a/hello-world/jsfuck.html b/hello-world/jsfuck.html new file mode 100644 index 00000000..c2d0af99 --- /dev/null +++ b/hello-world/jsfuck.html @@ -0,0 +1,7 @@ + + + + + diff --git a/hello-world/lucky.py b/hello-world/lucky.py new file mode 100644 index 00000000..efc51f10 --- /dev/null +++ b/hello-world/lucky.py @@ -0,0 +1,4 @@ +n=int(input("enter the number") +for i in range(n): + print("hello world!") + diff --git a/hello-world/shivanshu.py b/hello-world/shivanshu.py new file mode 100644 index 00000000..b1dbe1d8 --- /dev/null +++ b/hello-world/shivanshu.py @@ -0,0 +1 @@ +print("Hello wolrd!") diff --git a/hello-world/th.java b/hello-world/th.java new file mode 100644 index 00000000..aa5a223e --- /dev/null +++ b/hello-world/th.java @@ -0,0 +1,6 @@ +public class Hello +{ + public static void main(String[] args) { + System.out.println("Hello World..!"); + } +} diff --git a/hello-world/vishesh.py b/hello-world/vishesh.py new file mode 100644 index 00000000..8cde7829 --- /dev/null +++ b/hello-world/vishesh.py @@ -0,0 +1 @@ +print("hello world") diff --git a/hello.md b/hello.md new file mode 100644 index 00000000..f2a5efc5 --- /dev/null +++ b/hello.md @@ -0,0 +1,9 @@ +# Python +print("Hello World!") + +# Java +public class Main { + public static void main(String args[]) { + System.out.println("Hello World!"); + } +} diff --git a/helloHacktober.js b/helloHacktober.js new file mode 100644 index 00000000..e211c1dc --- /dev/null +++ b/helloHacktober.js @@ -0,0 +1,2 @@ +console.log("HELLO HACKTOBERFEST, This is a very early github interatcion I make!"); + diff --git a/hello_world.c b/hello_world.c new file mode 100644 index 00000000..ce669ae7 --- /dev/null +++ b/hello_world.c @@ -0,0 +1,7 @@ +#include + +int main(){ + printf("Hello World"); + + return 0; +} diff --git a/hellos/hello.c b/hellos/hello.c new file mode 100644 index 00000000..4600f849 --- /dev/null +++ b/hellos/hello.c @@ -0,0 +1,7 @@ +#include + +int main() +{ + puts("Hello Hacktoberfest!!"); + return 0; +} diff --git a/html/alert.html b/html/alert.html new file mode 100644 index 00000000..f09fd8e0 --- /dev/null +++ b/html/alert.html @@ -0,0 +1,15 @@ + + + + Alert in javascript + + + +

Click here

+ + + \ No newline at end of file diff --git a/html/bootstrap_form.html b/html/bootstrap_form.html new file mode 100644 index 00000000..13db8089 --- /dev/null +++ b/html/bootstrap_form.html @@ -0,0 +1,33 @@ + + + + Bootstrap Example + + + + + + + + +
+

Inline form with .sr-only class

+

Make the viewport larger than 768px wide to see that all of the form elements are inline, left aligned, and the labels are alongside.

+
+
+ + +
+
+ + +
+
+ +
+ +
+
+ + + diff --git a/html/form.html b/html/form.html new file mode 100644 index 00000000..6112251e --- /dev/null +++ b/html/form.html @@ -0,0 +1,20 @@ + + + + Form + + +
+ First name:
+
+ Middle name:
+
+ Last name:
+
+ Male
+ Female
+ Other

+ +
+ + diff --git a/html/home.html b/html/home.html index 593514cf..542417b5 100644 --- a/html/home.html +++ b/html/home.html @@ -6,10 +6,21 @@ Home - +

Hello world


-

Click Me!!

- +

Click Me!!

+
+ +
+

+ diff --git a/html/index.html b/html/index.html index 1bc8b9a5..88c6dfc6 100644 --- a/html/index.html +++ b/html/index.html @@ -5,9 +5,24 @@ HTML CHEAT SHEET + + + + + + Go to blog

Heading One

diff --git a/ilhamhelloworld.py b/ilhamhelloworld.py new file mode 100644 index 00000000..371997ca --- /dev/null +++ b/ilhamhelloworld.py @@ -0,0 +1 @@ +print("Halo, selamat datang di Hacktoberfest!") \ No newline at end of file diff --git a/integer_partition/IntegerPartition.py b/integer_partition/IntegerPartition.py new file mode 100644 index 00000000..4cbeec00 --- /dev/null +++ b/integer_partition/IntegerPartition.py @@ -0,0 +1,29 @@ +""" The (Linear) Integer Partition Problem into k equal parts """ +l = [7, 3, 2, 1, 5, 4, 8] +k = 3 + +n = len(l) +mat = [[l[0] for j in range(k)] for i in range(n)] +div = [[0 for i in range(k)] for i in range(n)] + +def partition(n, k, li): + if (k>0) : + print(l[div[n][k]+1:li]) + partition(div[n][k], k-1, div[n][k]+1) + else: + print(l[0:n+1]) + +for i in range(n): + mat[i][0] = sum(l[:i+1]) + +for i in range(1, k): + for j in range(1, n): + x = list() + for m in range(0,j): + x.append(max(mat[m][i-1], sum(l[m+1:j+1]))) + x.append(mat[j][i-1]) + mat[j][i] = min(x) + div[j][i] = x.index(min(x)) + +print("Partitions : ") +partition(n-1, k-1, n) \ No newline at end of file diff --git a/isPallindrome.py b/isPallindrome.py new file mode 100644 index 00000000..411cf225 --- /dev/null +++ b/isPallindrome.py @@ -0,0 +1,7 @@ +print("Enter the string to check") + t = input("Please enter a string") + +if(t == t[::-1]): + print("The string entered is palindrome") +else: + print("Not a palindrome") \ No newline at end of file diff --git a/isPrime.py b/isPrime.py new file mode 100644 index 00000000..1ed7c354 --- /dev/null +++ b/isPrime.py @@ -0,0 +1,21 @@ + +# Python program to display all the prime numbers within an interval + +# change the values of lower and upper for a different result +lower = 900 +upper = 1000 + +# uncomment the following lines to take input from the user +#lower = int(input("Enter lower range: ")) +#upper = int(input("Enter upper range: ")) + +print("Prime numbers between",lower,"and",upper,"are:") + +for num in range(lower,upper + 1): + # prime numbers are greater than 1 + if num > 1: + for i in range(2,num): + if (num % i) == 0: + break + else: + print(num) \ No newline at end of file diff --git a/is_it_prime.c b/is_it_prime.c new file mode 100644 index 00000000..19fb95b8 --- /dev/null +++ b/is_it_prime.c @@ -0,0 +1,25 @@ +#include +#include + +int main() +{ + int a,i,k=0; + scanf("%d",&a); + if( a < 0 ) + printf("it is negative"); + else if( a % 2 == 0 || a == 1 ) + printf("it is not prime"); + else + { + for( i = 3 ; i <= sqrt(a) ; i += 2 ) + if( a % i == 0 ) + { + k = 1; + break; + } + if( k ) + printf("it is not prime"); + else + printf("it is prime"); + } +} diff --git a/isogram_in_c/src/isogram.c b/isogram_in_c/src/isogram.c new file mode 100644 index 00000000..531d41b5 --- /dev/null +++ b/isogram_in_c/src/isogram.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include "isogram.h" + +bool is_isogram(const char phrase[]) +{ + int index = 0; + if (phrase == NULL) + { + return false; + } + index = strlen(phrase); + bool result = true; + + for (int i=0; i < index; i++) + { + for (int j=i+1; j < index; j++) + { + if (is_printable(phrase[i]) && is_printable(phrase[j])) + { + char temp1, temp2; + temp1 = capitalize(phrase[i]); + temp2 = capitalize(phrase[j]); + //printf("temp1 = %c, temp2 = %c \n", temp1, temp2); + if (temp1 == temp2) + result = false; + } + } + } + + return result; +} + +bool is_printable(const char x) +{ + bool result = false; + if ((x > 0x40 && x < 0x5B) || (x > 0x60 && x < 0x7B)) + result = true; + return result; +} + +char capitalize(const char x) +{ + char ret; + if ( x > 0x60 && x < 0x7B ) + ret = x - 32; + else + ret = x; + return ret; +} diff --git a/isogram_in_c/src/isogram.h b/isogram_in_c/src/isogram.h new file mode 100644 index 00000000..1cb13416 --- /dev/null +++ b/isogram_in_c/src/isogram.h @@ -0,0 +1,10 @@ +#ifndef ISOGRAM_H +#define ISOGRAM_H + +#include + +bool is_isogram(const char phrase[]); +bool is_printable(const char); +char capitalize(const char); + +#endif diff --git a/kmp-string.py b/kmp-string.py new file mode 100644 index 00000000..d8ad98da --- /dev/null +++ b/kmp-string.py @@ -0,0 +1,33 @@ +""" +Algorithm: Finds all matching substrings and outputs their positions. +Example: +KMP.search("racecarace","race") returns [0,7] +""" +class KMP: + def partial(self, pattern): + """ Calculate partial match table: String -> [Int]""" + ret = [0] + + for i in range(1, len(pattern)): + j = ret[i - 1] + while j > 0 and pattern[j] != pattern[i]: + j = ret[j - 1] + ret.append(j + 1 if pattern[j] == pattern[i] else j) + return ret + + def search(self, T, P): + """ + KMP search main algorithm: String -> String -> [Int] + Return all the matching position of pattern string P in S + """ + partial, ret, j = self.partial(P), [], 0 + + for i in range(len(T)): + while j > 0 and T[i] != P[j]: + j = partial[j - 1] + if T[i] == P[j]: j += 1 + if j == len(P): + ret.append(i - (j - 1)) + j = 0 + + return ret diff --git a/linkedlist operations/Node b/linkedlist operations/Node new file mode 100644 index 00000000..a8b2e7d6 --- /dev/null +++ b/linkedlist operations/Node @@ -0,0 +1,158 @@ +#include +#include + +struct Node { + int value; + struct Node *next; +}; + +struct Node* createNode( int n){ + struct Node *newNode = malloc(sizeof(struct Node)); + if(newNode) + { + newNode->value = n; + newNode->next = NULL; + } + return newNode; +} + +int sizeofList(struct Node *head) +{ + int count; + struct Node *curr; + if(head==NULL) + return 0; + if(head->next==NULL) + return 1; + + count=1; + curr=head; + while ( (curr = curr->next) != NULL ) + count++; + + return count; +} + + +void addNode(struct Node **head, int val){ + + struct Node *newNode = createNode(val); + struct Node *curr; + + if((*head)==NULL) + { + *head=newNode; + (*head)->next=NULL; + } + + else + { + curr = *head; + while((curr->next)!=NULL) + curr=curr->next; + curr->next=newNode; + } +} + + +void deleteNode(struct Node **head,int index){ + + struct Node *tmp; + struct Node *curr; + int i; + + + if(index>=sizeofList(*head)) + return; + + if(sizeofList(*head)==0) + return; + + else if(sizeofList(*head)==1) + { + free(*head); + *head=NULL; + return; + } + + else + { + if(index==0) + { + curr=(*head)->next; + (*head)->next=NULL; + free(*head); + *head=curr; + } + + else + { + curr=*head; + for(i=0;inext; + + tmp=curr->next; + curr->next=tmp->next; + tmp->next=NULL; + free(tmp); + } + } + + return; +} + +void printList(struct Node *head) +{ + int listSize=sizeofList(head); + + int i; + struct Node *curr; + if(listSize==0) + { + printf("Nothing to print!\n"); + return; + } + + curr=head; + for(i=0;ivalue); + curr=curr->next; + } +} + + +int main(int argc, char* argv[]) +{ + + struct Node *head; + + head=NULL; + printf("Initial list size: %d\n",sizeofList(head)); + printList(head); + printf("\n"); + + addNode(&head,10); + addNode(&head,20); + printf("List size after insertions: %d\n",sizeofList(head)); + printList(head); + printf("\n"); + + deleteNode(&head,0); + printf("List size after deletion: %d\n",sizeofList(head)); + printList(head); + printf("\n"); + + deleteNode(&head,0); + printf("List size after deletion: %d\n",sizeofList(head)); + printList(head); + printf("\n"); + + addNode(&head,30); + printf("List size after insertion: %d\n",sizeofList(head)); + printList(head); + printf("\n"); + + return 0; + +} diff --git a/linkedlist operations/deletemember.c b/linkedlist operations/deletemember.c new file mode 100644 index 00000000..c41ae035 --- /dev/null +++ b/linkedlist operations/deletemember.c @@ -0,0 +1,88 @@ +#include +#include +#include +struct cell{ + int content; + struct cell * next; + +}; +typedef struct cell cell; +cell *cell_create(int content){ + cell*a=(cell*)malloc(sizeof(cell)); + if(a==NULL){ + printf("heap alaninda yer ayrilamadi"); + + } + a->content=content; + a->next=NULL; + return a; + +} +void list_end_add(int content,cell**list_head){ + cell*a=cell_create(content); + if(*list_head==NULL){ + a->next=*list_head; + *list_head=a; + } + else{ + cell*x=*list_head; + while(x->next!=NULL){ + x=x->next; + + } + x->next=a; + } +} +void list_write(cell*list_head){ + if(list_head!=NULL){ + printf("%4d",list_head->content); + list_write(list_head->next); + + } + else + printf("\n"); +} + + + +void erase (int index,cell**list){ + int i=1; + cell*a; + cell*b=*list; + if(i==index){ + a=*list; + *list=(*list)->next; + free(a); + + + + } + else{ + while(i!=index-1){ + b=b->next; + i++; + } + a=b->next; + b->next=a->next; + free(a); + } + return *list; + +} +int main() +{ + cell*list=NULL; + + + list_end_add(1,&list); + list_end_add(2,&list); + list_end_add(3,&list); + list_end_add(6,&list); + list_write(list); + erase(1,&list); + list_write(list); + + + + return 0; +} diff --git a/linkedlist.py b/linkedlist.py new file mode 100755 index 00000000..56b63b9c --- /dev/null +++ b/linkedlist.py @@ -0,0 +1,30 @@ +class Node: + + def __init__(self,data): + self.data=data + self.next=None + +a=Node(96) +b=Node(2) +c=Node(52) +d=Node(18) +e=Node(36) +f=Node(13) +a.next=b +b.next=c +c.next=d +d.next=e +e.next=f +b=None +c=None +d=None +e=None +f=None + +a.next.next.next=a.next.next.next.next + + +temp=a +while temp!=None: + print(temp.data) + temp=temp.next diff --git a/linkedlist_2.c b/linkedlist_2.c new file mode 100644 index 00000000..7b8d3bf3 --- /dev/null +++ b/linkedlist_2.c @@ -0,0 +1,209 @@ +#include +#include +struct node{ + int data; + struct node* next; +}; +struct node* Start=NULL; +void insert(){ + int i,m,count=0; + struct node* t=NULL; + t=(struct node*)malloc(sizeof(struct node)); + + struct node* x=NULL; + struct node* z=NULL; + printf("Enter the position where you want to insert the element: "); + scanf("%d",&m); + + if((Start==NULL)&&(m!=0)) + printf("invalid\n"); + else if((Start==NULL)&&(m==0)){ + printf("Enter data: "); + scanf("%d",&(t->data)); + Start=t; + t->next=NULL; + } + else if((Start!=NULL)&&(m==0)){ + printf("Enter data: "); + scanf("%d",&(t->data)); + t->next=Start; + Start=t; + } + else{ + x=Start; + for (i = 0; i < m-1; i++){ + if (x->next==NULL){ + break; + } + x=x->next; + } + if (x->next==NULL){ + printf("Enter data: "); + scanf("%d",&t->data); + x->next=t; + t->next=NULL; + } + else{ + printf("Enter data: "); + scanf("%d",&t->data); + z=x->next; + x->next=t; + t->next=z; + } + } +} +void delete(){ + int c,i; + struct node* temp=Start; + struct node* b=NULL; + printf("Enter the position from where you want to delete the element\n"); + scanf("%d",&c); + if(Start==NULL) + printf("List is empty\n"); + else if((Start!=NULL)&&(c==0)){ + b=Start; + Start=b->next; + free(b); + } + else{ + for(i=0;inext==NULL){ + return; + } + b=temp; + temp=temp->next; + } + if(temp->next==NULL){ + b->next=NULL; + free(temp); + } + else{ + b->next=temp->next; + free(temp); + } + } +} +void display(){ + struct node* temp=Start; + if(temp==NULL) + printf("List is empty\n"); + else{ + while(temp!=NULL){ + printf("%d ",temp->data); + temp=temp->next; + } + printf("\n"); + } +} +void reverselist(){ + struct node *t=Start; + struct node *t1=t->next; + struct node *t2=t1->next; + Start->next=NULL; + while(t2!=NULL){ + t1->next=t; + t=t1; + t1=t2; + t2=t1->next; + } + t1->next=t; + Start=t1; +} +void sortlist(){ + struct node *t1=Start; + struct node *t2=t1->next; + struct node *t=NULL; + int flag=1; + while(flag){ + t=t1; + flag=0; + while(t2!=NULL){ + if (t1!=Start){ + if (t1->data>t2->data){ + t1->next=t2->next; + t->next=t2; + t2->next=t1; + t=t2; + t2=t1->next; + flag=1; + } + else{ + t=t->next; + t1=t1->next; + t2=t2->next; + } + } + else{ + if (t1->data>t2->data){ + Start=t2; + t1->next=t2->next; + t2->next=t1; + t2=t2->next; + t=Start; + flag=1; + } + else{ + t1=t1->next; + t2=t2->next; + } + } + } + /*if(t1->data>t2->data){ + t1->next=NULL; + t->next=t2; + t2->next=t1; + t1=Start; + t2=t1->next; + } + else{ + t1=Start; + t2=t1->next; + }*/ + t1=Start; + t2=t1->next; + } +} +void findbyvalue(){ + int a,count=1; + struct node* temp=Start; + printf("Enter the value you want to check if it is in the list or not: "); + scanf("%d",&a); + while(temp->next!=NULL){ + if (temp->data==a){ + break; + } + else{ + temp=temp->next; + count++; + } + } + if(temp->data==a) + printf("Value given by you is in the list and the number at which this entry is present is: %d\n",count); + else + printf("Given entry is not in the list\n"); +} +int main(){ + int ch; + while(1){ + printf("1. Add a number to the list\n2. Delete element of the list\n3. View list\n4. Find a value in the list\n5. Sort list\n6. Reverse the list\n7. Exit\n"); + scanf("%d",&ch); + switch(ch){ + case 1: insert(); + break; + case 2: delete(); + break; + case 3: display(); + break; + case 4: findbyvalue(); + break; + case 5: sortlist(); + break; + case 6: reverselist(); + break; + case 7: exit(0); + break; + default : printf("invalid"); + } + } + return 0; +} \ No newline at end of file diff --git a/linker/linker.java b/linker/linker.java new file mode 100644 index 00000000..2e7f4acf --- /dev/null +++ b/linker/linker.java @@ -0,0 +1,302 @@ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Scanner; + +public class lab1{ + public static void main(String[] args) { + //In order to use scanner and be an actual two pass linker, program assumes + //that the entire input will be entered twice + + Scanner myscanner = new Scanner (System.in); + int num_modules = myscanner.nextInt(); + + //for symbol table + HashMap mymap = new HashMap<>(); + + //for undefined symbols and their absolute address + HashMap undefined = new HashMap<>(); + + //for keeping track of # of uses of symbols + HashMap count = new HashMap<>(); + + //for keeping track of where (in which module) each variable is defined + HashMap symbModule = new HashMap<>(); + + //to help determine if a variable definiton is out of the range of size of the module + HashMap altered = new HashMap<>(); + + HashMap multiply_defined = new HashMap<>(); + + //for keeping track of base addresses for each module + int[] mylist = new int[num_modules+1]; + + //base address for module 1 is always 0 + mylist[1]=0; + + //pass #1 - find base address for each module and absolute address for each external symbol + int total_mod_size=0; + for(int i=1; i<=num_modules; i++) { + //get number of definitions + int num_def = myscanner.nextInt(); + + //relative location and absolute location + int relloc =0; + int absloc =0; + + if(num_def != 0) { + for(int j=1; j<=num_def; j++) { + //read in the definitions + String symbol = myscanner.next(); + symbModule.put(symbol, i); + + relloc = myscanner.nextInt(); + + absloc=relloc + total_mod_size; + + if(mymap.containsKey(symbol)) {multiply_defined.put(symbol,0);} + mymap.put(symbol, absloc); + altered.put(symbol, 0); + count.put(symbol, 0); + } + } + + skipUseList(myscanner); + + + + int module_size = myscanner.nextInt(); + + //check to see if address in definition exceeds size of module + for(String variable :symbModule.keySet()) { + if(symbModule.get(variable)==i) { + int absolute = mymap.get(variable); + int relative = absolute - total_mod_size; + if(relative>=module_size) { + relative = module_size -1; + absolute = relative + total_mod_size; + mymap.put(variable, absolute); + altered.put(variable, 1); + } + } + } + + total_mod_size += module_size; + + //keep track of where the next module begins + if(i99999){ + //need to get rid of the two digits from the right + memory[x] /= 10; + memory[x] -= memory[x]%10; + memory[x] /= 10; + System.out.println(x+": "+memory[x]); + } + + + else if(rem<=299 ) { + if(mem_index_count[x]>1) { + System.out.println(x+": "+memory[x]+" Error: Multiple variables used in instruction; all but last ignored."); + } + else { + System.out.println(x+": "+memory[x]); + } + } + + + else{ + memory[x]-=rem; memory[x]+=299; + System.out.println(x+": "+memory[x]+" Error: Absolute address exceed legal machine size; largest legal value used."); + + } + } + + + else { + if(mem_index_count[x]>1) { + System.out.println(x+": "+memory[x]+" Error(#1): "+undefined.get(x)+" is not defined; 111 used. Error(#2): Multiple variables used in instruction; all but last ignored."); + } + else { + System.out.println(x+": "+memory[x]+" Error: "+undefined.get(x)+" is not defined; 111 used."); + } + } + } + System.out.println(); + //unused variables + for(String s : count.keySet()) { + int check = count.get(s); + int mod=0; + if(check ==0) { + //find which module the variable was defined in + /*for(int x=2; x<=num_modules; x++) { + if(mymap.get(s)data=value; + temp->next=NULL; + return temp; + } +} + +void insert_beg() +{ + int value; + cout<<"Enter value to be inserted: "; + cin>>value; + struct node *temp,*p; + temp=create(value); + if(start==NULL) + { + start=temp; + start->next=NULL; + } + else + { + p=start; + start=temp; + start->next=p; + } + cout<<"Element inserted at begining\n"; +} + +void insert_last() +{ + int value; + cout<<"Enter value to be inserted: "; + cin>>value; + struct node *temp,*p; + temp=create(value); + p=start; + while(p->next!=NULL) + { + p=p->next; + } + temp->next=NULL; + p->next=temp; + cout<<"Element inserted at last\n"; +} + +void insert_pos() +{ + int value,pos,c=0,i; + cout<<"Enter value to be inserted: "; + cin>>value; + struct node *temp,*p,*t1; + temp=create(value); + cout<<"Enter position"; + cin>>pos; + p=start; + while(p!=NULL) + { + p=p->next; + c++; + } + if(pos==1) + { + if(start==NULL) + { + start=temp; + start->next=NULL; + } + else + { + t1=start; + start=temp; + start->next=t1; + } + } + else if(pos>1 && pos<=c) + { + p = start; + for(i=1;inext; + } + t1->next=temp; + temp->next=p; + } + else + cout<<"Invalid Position"; + +} +void display() +{ + struct node *temp; + if(start==NULL) + { + cout<<"List is empty"; + return; + } + temp=start; + while(temp!=NULL) + { + cout<data<<"->"; + temp=temp->next; + } + cout<<"NULL\n"; +} + +int main() +{ + int ch,nodes,element,pos,i; + start=NULL; + while(1) + { + cout<<"1.Insert Node at beginning"<>ch; + switch(ch) + { + case 1: insert_beg(); + break; + case 2: insert_last(); + break; + case 3: insert_pos(); + break; + case 8: display(); + break; + default:exit; + break; + } + } + return 0; +} diff --git a/longest_common_subsequence/LCS.py b/longest_common_subsequence/LCS.py new file mode 100644 index 00000000..98df1732 --- /dev/null +++ b/longest_common_subsequence/LCS.py @@ -0,0 +1,36 @@ +""" longest common subsequence """ +str1 = input("Enter the string : ") +str2 = input("Enter the string to compare : ") +n = len(str1)+1 +m = len(str2)+1 + +arr = [[0 for j in range(m)] for i in range(n)] + +def check(i, j): + if str1[i] == str2[j] : + return 1 + else: + return 0 + +for i in range(1,n): + for j in range(1,m): + if check(i-1,j-1): + arr[i][j] = arr[i-1][j-1]+1 + lcs += str1[i-1] + else: + arr[i][j] = max([arr[i-1][j], arr[i][j-1]]) + +lcs = "" +i,j = n-1,m-1 +while (i!=0 or j!=0): + if arr[i][j]==arr[i-1][j-1]+1: + lcs = str1[i-1] + lcs + i -= 1 + j -= 1 + elif arr[i][j] == arr[i-1][j]: + i -= 1 + else: + j -= 1 + +print("Longest Common Subsequence : "+lcs) +print("Length of Longest Increasing Subsequence : "+str(arr[n-1][m-1])) \ No newline at end of file diff --git a/longest_common_subsequence/LCS_Recursion.py b/longest_common_subsequence/LCS_Recursion.py new file mode 100644 index 00000000..95693d36 --- /dev/null +++ b/longest_common_subsequence/LCS_Recursion.py @@ -0,0 +1,21 @@ +""" Longest Common Subsequence using recursion """ +str1 = input("Enter the string : ") +str2 = input("Enter the string to compare : ") +n = len(str1) +m = len(str2) + +def check(i, j): + if str1[i] == str2[j]: + return True + else: + return False + +def lcs(i, j): + if i == n or j == m : + return 0 + elif check(i, j): + return 1+lcs(i+1, j+1) + else : + return max(lcs(i+1, j), lcs(i, j+1)) + +print("Length of Longest Increasing Subsequence : "+str(lcs(0, 0))) \ No newline at end of file diff --git a/longest_common_subsequence/lcs.java b/longest_common_subsequence/lcs.java new file mode 100644 index 00000000..2e3fec40 --- /dev/null +++ b/longest_common_subsequence/lcs.java @@ -0,0 +1,37 @@ +/* A Naive recursive implementation of LCS problem in java*/ +public class LongestCommonSubsequence +{ + + /* Returns length of LCS for X[0..m-1], Y[0..n-1] */ + int lcs( char[] X, char[] Y, int m, int n ) + { + if (m == 0 || n == 0) + return 0; + if (X[m-1] == Y[n-1]) + return 1 + lcs(X, Y, m-1, n-1); + else + return max(lcs(X, Y, m, n-1), lcs(X, Y, m-1, n)); + } + + /* Utility function to get max of 2 integers */ + int max(int a, int b) + { + return (a > b)? a : b; + } + + public static void main(String[] args) + { + LongestCommonSubsequence lcs = new LongestCommonSubsequence(); + String s1 = "AGGTAB"; + String s2 = "GXTXAYB"; + + char[] X=s1.toCharArray(); + char[] Y=s2.toCharArray(); + int m = X.length; + int n = Y.length; + + System.out.println("Length of LCS is" + " " + + lcs.lcs( X, Y, m, n ) ); + } + +} diff --git a/longest_increasing_subsequence/LIS.py b/longest_increasing_subsequence/LIS.py new file mode 100644 index 00000000..1e9ee748 --- /dev/null +++ b/longest_increasing_subsequence/LIS.py @@ -0,0 +1,18 @@ +""" Longest Incresing Subsequence """ +arr = [3,4,-1,0,2,3] +n = len(arr) + +lis = [1 for i in range(n)] +lis_list = [[arr[i]] for i in range(n)] + +for i in range(1,n): + for j in range(0,i): + if(arr[j]<=arr[i]): + lis[i] = max(lis[i], lis[j]+1) + lis_list[j].append(arr[i]) + +max_len = max(lis) +print("Length of Longest Incresing Subsequence : " + str(max_len)) +for seq in lis_list: + if len(seq) == max_len: + print(seq) \ No newline at end of file diff --git a/map.cpp b/map.cpp index d263b88f..e410169b 100644 --- a/map.cpp +++ b/map.cpp @@ -9,9 +9,9 @@ int main() map m; //copying an array into a map - int arr[10] = {12,14,15,16,17,17,16,60,12,1}; + int arr[11] = {12,14,15,16,17,17,16,60,12,1,56}; map map1; - for(int i=0;i<10;i++) + for(int i=0;i<11;i++) { map1[arr[i]]++; } @@ -22,4 +22,4 @@ int main() { cout<first<<" "<second; } -} \ No newline at end of file +} diff --git a/matrix diagonal addition.c b/matrix diagonal addition.c new file mode 100644 index 00000000..325023a2 --- /dev/null +++ b/matrix diagonal addition.c @@ -0,0 +1,22 @@ +#include +main(){ +int i,j,k,sum=0,ullu=0; +scanf("%d",&i); +int a[i][i]; +for(k=0;k<=(i-1);k++){ + for(j=0;j<=(i-1);j++) + scanf("%d",&a[k][j]); +} +for(j=0;j<=(i-1);j++) + sum=sum+a[j][j]; +k=(i-1); +for(j=0;j<=(i-1);j++){ + ullu=ullu+a[j][k]; + k--; +} +if(ullu>sum) + sum=ullu-sum; +else + sum=sum-ullu; +printf("%d",sum); +} diff --git a/matrix_chain_multiplication/matrix_chain_multiplication.py b/matrix_chain_multiplication/matrix_chain_multiplication.py new file mode 100644 index 00000000..9b3ae64f --- /dev/null +++ b/matrix_chain_multiplication/matrix_chain_multiplication.py @@ -0,0 +1,18 @@ +""" Matrix Chain Multiplication """ +dim = [2,3,4,1,5,2] + +n = len(dim)-1 +mul = [[0 for j in range(n)] for i in range(n)] +p = [[0 for j in range(n)] for i in range(n)] + +for i in range(0,n-1): + for j in range(0, n-1-i): + x = list() + for k in range(j, j+i+1): + print(j, k, j+i+1) + x.append(mul[j][k]+mul[k+1][j+i+1]+dim[j]*dim[k+1]*dim[j+i+1+1]) + mul[j][j+i+1] = min(x) + p[j][j+i+1] = j+x.index(min(x))+1 + +print(mul) +print(p) \ No newline at end of file diff --git a/matrixmul.py b/matrixmul.py new file mode 100644 index 00000000..48eea075 --- /dev/null +++ b/matrixmul.py @@ -0,0 +1,25 @@ +# Program to multiply two matrices using nested loops + +# 3x3 matrix +X = [[12,7,3], + [4 ,5,6], + [7 ,8,9]] +# 3x4 matrix +Y = [[5,8,1,2], + [6,7,3,0], + [4,5,9,1]] +# result is 3x4 +result = [[0,0,0,0], + [0,0,0,0], + [0,0,0,0]] + +# iterate through rows of X +for i in range(len(X)): + # iterate through columns of Y + for j in range(len(Y[0])): + # iterate through rows of Y + for k in range(len(Y)): + result[i][j] += X[i][k] * Y[k][j] + +for r in result: + print(r) \ No newline at end of file diff --git a/merge_sort.cpp b/merge_sort.cpp new file mode 100644 index 00000000..8a9aea61 --- /dev/null +++ b/merge_sort.cpp @@ -0,0 +1,73 @@ +#include +#include +#include +#include + +using namespace std; + +void merge(int v[],int p,int q,int r){ + int a[r-p+1]; + int i=p,j=q+1,k=0; + while(i<=q && j<=r){ + if(v[i]q){ + while(j<=r){ + a[k]=v[j]; + k=k+1; + j=j+1; + } + } + else{ + while(i<=q){ + a[k]=v[i]; + i=i+1; + k=k+1; + } + } + for(int i=p;i<=r;i++){ + v[i]=a[i-p]; + } + +} + +void merge_sort(int v[],int p,int r){ + if(p v; + int num; + int count; + while(file>>num){ + v.push_back(num); + } + count=v.size(); + int b[v.size()]; + for(int i=0;i +#include + +// Merges two subarrays of arr[]. +// First subarray is arr[l..m] +// Second subarray is arr[m+1..r] +void merge(int arr[], int l, int m, int r) +{ + int i, j, k; + int n1 = m - l + 1; + int n2 = r - m; + + /* create temp arrays */ + int L[n1], R[n2]; + + /* Copy data to temp arrays L[] and R[] */ + for (i = 0; i < n1; i++) + L[i] = arr[l + i]; + for (j = 0; j < n2; j++) + R[j] = arr[m + 1+ j]; + + /* Merge the temp arrays back into arr[l..r]*/ + i = 0; // Initial index of first subarray + j = 0; // Initial index of second subarray + k = l; // Initial index of merged subarray + while (i < n1 && j < n2) + { + if (L[i] <= R[j]) + { + arr[k] = L[i]; + i++; + } + else + { + arr[k] = R[j]; + j++; + } + k++; + } + + /* Copy the remaining elements of L[], if there + are any */ + while (i < n1) + { + arr[k] = L[i]; + i++; + k++; + } + + /* Copy the remaining elements of R[], if there + are any */ + while (j < n2) + { + arr[k] = R[j]; + j++; + k++; + } +} + +/* l is for left index and r is right index of the + sub-array of arr to be sorted */ +void mergeSort(int arr[], int l, int r) +{ + if (l < r) + { + // Same as (l+r)/2, but avoids overflow for + // large l and h + int m = l+(r-l)/2; + + // Sort first and second halves + mergeSort(arr, l, m); + mergeSort(arr, m+1, r); + + merge(arr, l, m, r); + } +} +} diff --git a/mergesort/msort.py b/mergesort/msort.py new file mode 100644 index 00000000..679c618e --- /dev/null +++ b/mergesort/msort.py @@ -0,0 +1,59 @@ +# Merges two subarrays of arr[]. +# First subarray is arr[l..m] +# Second subarray is arr[m+1..r] +def merge(arr, l, m, r): + n1 = m - l + 1 + n2 = r- m + + # create temp arrays + L = [0] * (n1) + R = [0] * (n2) + + # Copy data to temp arrays L[] and R[] + for i in range(0 , n1): + L[i] = arr[l + i] + + for j in range(0 , n2): + R[j] = arr[m + 1 + j] + + # Merge the temp arrays back into arr[l..r] + i = 0 # Initial index of first subarray + j = 0 # Initial index of second subarray + k = l # Initial index of merged subarray + + while i < n1 and j < n2 : + if L[i] <= R[j]: + arr[k] = L[i] + i += 1 + else: + arr[k] = R[j] + j += 1 + k += 1 + + # Copy the remaining elements of L[], if there + # are any + while i < n1: + arr[k] = L[i] + i += 1 + k += 1 + + # Copy the remaining elements of R[], if there + # are any + while j < n2: + arr[k] = R[j] + j += 1 + k += 1 + +# l is for left index and r is right index of the +# sub-array of arr to be sorted +def mergeSort(arr,l,r): + if l < r: + + # Same as (l+r)/2, but avoids overflow for + # large l and h + m = (l+(r-1))/2 + + # Sort first and second halves + mergeSort(arr, l, m) + mergeSort(arr, m+1, r) + merge(arr, l, m, r) diff --git a/n_queen/NQueen.py b/n_queen/NQueen.py new file mode 100644 index 00000000..cf82a9a4 --- /dev/null +++ b/n_queen/NQueen.py @@ -0,0 +1,32 @@ +n = int(input("Enter the number of Queens : ")) +Queen = [i for i in range(n)] + +def place(i, j): + for k in range(i): + if (Queen[k] == j or abs(Queen[k]-j) == abs(i-k)): + return False + return True + +def print_queen(): + print("\nPlaces of Queens\n|", end="") + for i in range(n): + for j in range(Queen[i]): + print(" |", end="") + print("Q |", end="") + for j in range(n-Queen[i]-1): + print(" |", end="") + if(not i == n-1): + print("\n|", end="") + print() + +def n_queen(i): + if i +#include +#include + +using namespace std; + +int main(){ + int max, random_number, i; + + cout << "Welcome to the Random Number Generator." << endl; + cout << "Please input the max number: "; + cin >> max; + + srand(time(0)); + random_number = (rand() % max) + 1; + + cout << random_number << endl; + + return 0; +} \ No newline at end of file diff --git a/palindrome.c b/palindrome.c new file mode 100644 index 00000000..52daeeee --- /dev/null +++ b/palindrome.c @@ -0,0 +1,59 @@ +/* + + Palindrome number in C using remainder (%) + @author - bhansa + @createdon - 09/07/2017 + +*/ + +#include + +int main(){ + + int number, num, revnumber = 0, rem; + + scanf("%d", &number); + + //save it + num = number; + + //reverse the number + while(num != 0){ + // understand the process here + /* + Okay, Let's suppose num or number = 121 + It goes on till the num is not zero(0) + loop1 : + rem = 121%10 -> 1 + revnumber = 0*10 + 1 -> 1 + num = 121/10 -> 12 + Loop2 : + rem = 12%10 -> 2 (taking out the last corner integer) + revnumber = 1*10 + 2 -> 12 + num = 12/10 -> 12 -> 1 + + loop3 : + predict it. + + */ + rem = num%10; + revnumber = revnumber*10 + rem; + num /= 10; + + } + + //now see if the original and this reversed number is same or not + if(number == revnumber){ + printf("%d is a palindrome.\n",n); + } + else + printf("%d is not a palindrome.\n",n); + +} + +/* Example + Input- 121 + Output - 121 is a palindrome number. + Input - 122 + Output - 122 is not a palindrome number. + */ diff --git a/palindrome.cpp b/palindrome.cpp new file mode 100644 index 00000000..9514379b --- /dev/null +++ b/palindrome.cpp @@ -0,0 +1,26 @@ +#include +#include +using namespace std; + +void isPalindrome(string str) +{ + int l=0; + int h=str.length()-1; + + while(h>l) + { + if(str[l++]!=str[h--]) + { + cout<<"Not Palindrome\n"; + return; + } + } + cout<<"Palindrome\n"; +} + +int main() +{ + isPalindrome("abba"); + isPalindrome("bacha"); + isPalindrome("neen"); +} diff --git a/palindrome/Ekansh_palindrome.cpp b/palindrome/Ekansh_palindrome.cpp new file mode 100644 index 00000000..43305dc5 --- /dev/null +++ b/palindrome/Ekansh_palindrome.cpp @@ -0,0 +1,34 @@ +#include +#include + +using namespace std; + +int main() +{ + string s; + bool check; + cin >> s; + for(long long int i=0; i; +$t=$n; +$s=0; +while($n>0) +{ +$r=$n%10; +$s=($s*10)+$r; +$n=int($n/10); +} +if($t==$s) +{ +print"Number is palindrome\n"; +} +else +{ +print"Number is not palindrome\n"; +} \ No newline at end of file diff --git a/palindrome/palindromeCheck.java b/palindrome/palindromeCheck.java new file mode 100644 index 00000000..1e651aa4 --- /dev/null +++ b/palindrome/palindromeCheck.java @@ -0,0 +1,26 @@ +import java.util.Scanner; +class PalindromeCheck { + public static void main (String args[]) { + System.out.print ("Enter a number: "); + int num = new Scanner(System.in).nextInt(); + + if (checkPalindrome(num)) + System.out.println("It is a palindrome!"); + else + System.out.println("It is not a palindrome."); + } + + private static boolean checkPalindrome(int n) { + String reverse = ""; // To store the reversed number + String number = Integer.toString(n); + + for (int i = number.length() - 1; i >= 0; i--) { + reverse += number.charAt(i); + } + + if (reverse.equals(number)) + return true; + else + return false; + } +} \ No newline at end of file diff --git a/palindrome/palindrome_split_join.py b/palindrome/palindrome_split_join.py new file mode 100644 index 00000000..1ff36e1b --- /dev/null +++ b/palindrome/palindrome_split_join.py @@ -0,0 +1,31 @@ +""" +A version of palindrome with more documentation +so beginners can see what is happening step by step. + +Author: Collin Cates +""" + +def is_palindrome(): + """Check if a word is a palindrome""" + + # Ask user for a word, then make the word lowercase + word = input("Enter a word: ").lower() + + # Use list comprehension on word + letters = [letter for letter in word] + + # Reverse the list of letters + reversed_letters = letters[::-1] + + # Join the reversed letters into a reversed word + reversed_word = ''.join(reversed_letters) + + # Compare word to reversed_word + if word == reversed_word: + print(f"\n{word} is a palindrome!\n") + else: + print(f"\n{word} is not a palindrome.\n") + + +if __name__ == "__main__": + is_palindrome() diff --git a/palindrome/palindrome_two.js b/palindrome/palindrome_two.js new file mode 100644 index 00000000..171c6b43 --- /dev/null +++ b/palindrome/palindrome_two.js @@ -0,0 +1,15 @@ +const palindrome = (num) => { + if (num < 10) { + return true + }; + + const numArr = num.toString().split(""); + + let reverse = ""; + + for (let char of numArr) { + reverse = char + reverse + }; + + return num.toString() === reverse; +} diff --git a/palindrome/palindromes.py b/palindrome/palindromes.py new file mode 100644 index 00000000..87f7cc1f --- /dev/null +++ b/palindrome/palindromes.py @@ -0,0 +1,22 @@ +# function which return reverse of a string +def reverse(s): + return s[::-1] + +def isPalindrome(s): + # Calling reverse function + rev = reverse(s) + + # Checking if both string are equal or not + if (s == rev): + return True + return False + + +# Driver code +s = "malayalam" +ans = isPalindrome(s) + +if ans == 1: + print("Yes") +else: + print("No") diff --git a/pangram.c b/pangram.c new file mode 100644 index 00000000..4b5c8079 --- /dev/null +++ b/pangram.c @@ -0,0 +1,48 @@ +#include +#include + +void main() +{ + char s[100]; + int i,used[26]={0},total=0; + clrscr(); + + printf("\n Enter the String:\n"); + gets(s); + + for(i=0;s[i]!='\0';i++) + { + if('a'<=s[i] && s[i]<='z') + { + total+=!used[s[i]-'a']; + used[s[i]-'a']=1; + } + else if('A'<=s[i] && s[i]<='Z') + { + total+=!used[s[i]-'A']; + used[s[i]-'A']=1; + } + } + + if(total==26) + { + printf("\n The Entered String is a Pangram String."); + } + else + { + printf("\n The Entered String is not a Pangram String."); + } + getch(); +} +/* Example +Input- +Enter the String: +The quick brown fox jumps over the lazy dog. +Output- +The Entered String is a Pangram String. +Input- +Enter the String: +I am a student. +Output- +The Entered String is not a Pangram String. +*/ diff --git a/pangram/pangram.cpp b/pangram/pangram.cpp new file mode 100644 index 00000000..4b6561f3 --- /dev/null +++ b/pangram/pangram.cpp @@ -0,0 +1,55 @@ + +// A C++ Program to check if the given +// string is a pangram or not +#include +using namespace std; + +// Returns true if the string is pangram else false +bool checkPangram (string &str) +{ + // Create a hash table to mark the characters + // present in the string + vector mark(26, false); + + // For indexing in mark[] + int index; + + // Traverse all characters + for (int i=0; i> num; if (perfect_square(num)) - {cout << num << " is a perfect square!"} + { + cout << num << " is a perfect square!"; + } else - {cout << num << " is not a perfect square!"} + { + cout << num << " is not a perfect square!"; + } } diff --git a/phone.cpp b/phone.cpp index c3914748..e1d9c9db 100644 --- a/phone.cpp +++ b/phone.cpp @@ -14,7 +14,7 @@ int stringdigit(string str) } -int main(void) +int main() { cout << "Please enter a phone number: "; string number; @@ -28,4 +28,5 @@ int main(void) cout << "is a valid phone number" << endl; + return 0; } diff --git a/playfair cipher.c b/playfair cipher.c new file mode 100644 index 00000000..d415c996 --- /dev/null +++ b/playfair cipher.c @@ -0,0 +1,185 @@ +#include +#include +int check(char table[5][5],char k) +{ +int i,j; +for(i=0;i<5;++i) +for(j=0;j<5;++j) +{ +if(table[i][j]==k) +return 0; +} +return 1; +} +void main() +{ +int i,j,len; +char table[5][5]; +for(i=0;i<5;++i) +for(j=0;j<5;++j) +table[i][j]='0'; +printf("\n\nApplying Polyalphabetic Substitution cipher (Playfair Cipher)\n\n"); +printf("How many alphabets are there in the key : "); +scanf("%d",&len); +char key[len]; +printf("\nPlease enter the key text : "); +for(i=-1;ilen) +goto l1; +flag=check(table,key[count]); +++count; +} +table[i][j]=key[(count-1)]; +} +} +l1:printf("\n"); +int val=97; +for(i=0;i<5;++i) +{ +for(j=0;j<5;++j) +{ +if(table[i][j]>=97 && table[i][j]<=123) +{} +else +{ +flag=0; +while(flag!=1) +{ +if('j'==(char)val) +++val; +flag=check(table,(char)val); +++val; +} +table[i][j]=(char)(val-1); +} +} +} +printf("\nTable of key is : \n"); +for(i=0;i<5;++i) +{ +for(j=0;j<5;++j) +{ +printf("%c ",table[i][j]); +} +printf("\n"); +} +int l=0; +printf("\nWhat is the length of plain text(without spaces) you want to encrypt :"); +scanf("%d",&l); +printf("\nPlease enter the Plain text : "); +char p[l]; +for(i=-1;i !(2 until num).exists(num % _ == 0)).toList + } +} diff --git a/prime/isPrime.hs b/prime/isPrime.hs new file mode 100644 index 00000000..c2b2b028 --- /dev/null +++ b/prime/isPrime.hs @@ -0,0 +1 @@ +isPrime k = null [ x | x <- [2..k - 1], k `mod`x == 0] \ No newline at end of file diff --git a/prime/isPrime.js b/prime/isPrime.js new file mode 100644 index 00000000..4c1e935c --- /dev/null +++ b/prime/isPrime.js @@ -0,0 +1,5 @@ +function isPrime(num) { + for(var i = 2; i < num; i++) + if(num % i === 0) return false; + return num !== 1 && num !== 0; +} diff --git a/prime/list_of_prime.py b/prime/list_of_prime.py index 38de12c4..7db9ceb6 100644 --- a/prime/list_of_prime.py +++ b/prime/list_of_prime.py @@ -1,15 +1,11 @@ -number = int(input("Input a number to generate a list of prime numbers smaller itself: ")) +number = int(input("Input a number to generate a list of prime numbers up to your number: ")) def is_prime(num): for i in range(2, num): if num % i == 0: return False return True -print("Prime numbers till "); -print(nummer); -print("\n"); +print(f"Prime numbers til {number}:\n") for i in range(2, number+1): if is_prime(i): - print(i) - print("\n"); - + print(i, "\n") diff --git a/prime/prime_list.cpp b/prime/prime_list.cpp new file mode 100644 index 00000000..106374f4 --- /dev/null +++ b/prime/prime_list.cpp @@ -0,0 +1,26 @@ +//generates a list of prime numbers upto a certain number + +#include +#include + +void check_prime(int m) +{ int i,c; + c=0; + for(i=2; i> n; +for(i=2; i<=n; i++) +{ check_prime(i);} +getch(); +} diff --git a/prime/primetoinfinity.py b/prime/primetoinfinity.py new file mode 100644 index 00000000..4e254a12 --- /dev/null +++ b/prime/primetoinfinity.py @@ -0,0 +1,19 @@ + +primelist = [2,3] +prime = 3 + +print 2 +print 3 + + +while True: + prime=prime+1 + + for x in primelist: + + if (prime) % x == 0: + break + + if x == primelist[-1]: + primelist.append(prime) + print (prime) diff --git a/print_elements_in_linkedlist.cpp b/print_elements_in_linkedlist.cpp new file mode 100644 index 00000000..2db1e7a7 --- /dev/null +++ b/print_elements_in_linkedlist.cpp @@ -0,0 +1,49 @@ +#include +using namespace std; + +struct Node +{ + int data; + struct Node* next; +}; + +void Print(struct Node *n) +{ int length=0; + while (n!=NULL) + { + n->data; + + + length++; + if (length==1) + cout<data; + + n = n->next; + } + +} + +int main() +{ + struct Node* head =NULL; + struct Node* second =NULL; + struct Node* third =NULL; + + head = (struct Node*)malloc (sizeof(struct Node)); + second = (struct Node*)malloc (sizeof(struct Node)); + third = (struct Node*)malloc (sizeof(struct Node)); + + + head->data = 10; + head->next = second; + + second->data = 20; + second->next = third; + + third->data = 30; + third->next = NULL; + + Print(second); + + return 0; +} diff --git a/project_UAS2/build.xml b/project_UAS2/build.xml new file mode 100644 index 00000000..a4e0ac8c --- /dev/null +++ b/project_UAS2/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project project_UAS2. + + + diff --git a/project_UAS2/build/classes/projectUAS3/ProjectUASv3.class b/project_UAS2/build/classes/projectUAS3/ProjectUASv3.class new file mode 100644 index 00000000..91cab478 Binary files /dev/null and b/project_UAS2/build/classes/projectUAS3/ProjectUASv3.class differ diff --git a/project_UAS2/build/classes/projectUAS3/ProjectUASv3Insertion.class b/project_UAS2/build/classes/projectUAS3/ProjectUASv3Insertion.class new file mode 100644 index 00000000..887bd2ce Binary files /dev/null and b/project_UAS2/build/classes/projectUAS3/ProjectUASv3Insertion.class differ diff --git a/project_UAS2/build/classes/projectUAS3/datatumbuhan.class b/project_UAS2/build/classes/projectUAS3/datatumbuhan.class new file mode 100644 index 00000000..9b529bc9 Binary files /dev/null and b/project_UAS2/build/classes/projectUAS3/datatumbuhan.class differ diff --git a/project_UAS2/build/classes/projectUAS3/datatumbuhan1.class b/project_UAS2/build/classes/projectUAS3/datatumbuhan1.class new file mode 100644 index 00000000..51a83917 Binary files /dev/null and b/project_UAS2/build/classes/projectUAS3/datatumbuhan1.class differ diff --git a/project_UAS2/build/classes/projectUAS3/test5.class b/project_UAS2/build/classes/projectUAS3/test5.class new file mode 100644 index 00000000..63d23895 Binary files /dev/null and b/project_UAS2/build/classes/projectUAS3/test5.class differ diff --git a/project_UAS2/build/classes/projectUAS3/tumbuhan$datatumbuhan.class b/project_UAS2/build/classes/projectUAS3/tumbuhan$datatumbuhan.class new file mode 100644 index 00000000..cc35acbf Binary files /dev/null and b/project_UAS2/build/classes/projectUAS3/tumbuhan$datatumbuhan.class differ diff --git a/project_UAS2/build/classes/projectUAS3/tumbuhan.class b/project_UAS2/build/classes/projectUAS3/tumbuhan.class new file mode 100644 index 00000000..b4562b48 Binary files /dev/null and b/project_UAS2/build/classes/projectUAS3/tumbuhan.class differ diff --git a/project_UAS2/build/classes/projectUAS3/tumbuhan1.class b/project_UAS2/build/classes/projectUAS3/tumbuhan1.class new file mode 100644 index 00000000..48180e26 Binary files /dev/null and b/project_UAS2/build/classes/projectUAS3/tumbuhan1.class differ diff --git a/project_UAS2/build/classes/project_uas2/ProjectUASv3.class b/project_UAS2/build/classes/project_uas2/ProjectUASv3.class new file mode 100644 index 00000000..442b2bcd Binary files /dev/null and b/project_UAS2/build/classes/project_uas2/ProjectUASv3.class differ diff --git a/project_UAS2/build/classes/project_uas2/Project_UAS2.class b/project_UAS2/build/classes/project_uas2/Project_UAS2.class new file mode 100644 index 00000000..e4a663be Binary files /dev/null and b/project_UAS2/build/classes/project_uas2/Project_UAS2.class differ diff --git a/project_UAS2/build/classes/project_uas2/UrutanString.class b/project_UAS2/build/classes/project_uas2/UrutanString.class new file mode 100644 index 00000000..b9955c60 Binary files /dev/null and b/project_UAS2/build/classes/project_uas2/UrutanString.class differ diff --git a/project_UAS2/build/classes/project_uas2/project_UAS2_shellshort.class b/project_UAS2/build/classes/project_uas2/project_UAS2_shellshort.class new file mode 100644 index 00000000..96596710 Binary files /dev/null and b/project_UAS2/build/classes/project_uas2/project_UAS2_shellshort.class differ diff --git a/project_UAS2/build/classes/project_uas2/tumbuhan$ProjectUASv3.class b/project_UAS2/build/classes/project_uas2/tumbuhan$ProjectUASv3.class new file mode 100644 index 00000000..2822525e Binary files /dev/null and b/project_UAS2/build/classes/project_uas2/tumbuhan$ProjectUASv3.class differ diff --git a/project_UAS2/build/classes/project_uas2/tumbuhan$datatumbuhan.class b/project_UAS2/build/classes/project_uas2/tumbuhan$datatumbuhan.class new file mode 100644 index 00000000..57850062 Binary files /dev/null and b/project_UAS2/build/classes/project_uas2/tumbuhan$datatumbuhan.class differ diff --git a/project_UAS2/build/classes/project_uas2/tumbuhan.class b/project_UAS2/build/classes/project_uas2/tumbuhan.class new file mode 100644 index 00000000..860ce33f Binary files /dev/null and b/project_UAS2/build/classes/project_uas2/tumbuhan.class differ diff --git a/project_UAS2/manifest.mf b/project_UAS2/manifest.mf new file mode 100644 index 00000000..1574df4a --- /dev/null +++ b/project_UAS2/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/project_UAS2/nbproject/build-impl.xml b/project_UAS2/nbproject/build-impl.xml new file mode 100644 index 00000000..de1dbca9 --- /dev/null +++ b/project_UAS2/nbproject/build-impl.xml @@ -0,0 +1,1420 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/project_UAS2/nbproject/genfiles.properties b/project_UAS2/nbproject/genfiles.properties new file mode 100644 index 00000000..4a2bf6ae --- /dev/null +++ b/project_UAS2/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=63d11498 +build.xml.script.CRC32=9aebcd6f +build.xml.stylesheet.CRC32=8064a381@1.80.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=63d11498 +nbproject/build-impl.xml.script.CRC32=aed54be6 +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/project_UAS2/nbproject/private/private.properties b/project_UAS2/nbproject/private/private.properties new file mode 100644 index 00000000..805d58a5 --- /dev/null +++ b/project_UAS2/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=C:\\Users\\USER\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/project_UAS2/nbproject/private/private.xml b/project_UAS2/nbproject/private/private.xml new file mode 100644 index 00000000..6807a2ba --- /dev/null +++ b/project_UAS2/nbproject/private/private.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/project_UAS2/nbproject/project.properties b/project_UAS2/nbproject/project.properties new file mode 100644 index 00000000..d2ef2d22 --- /dev/null +++ b/project_UAS2/nbproject/project.properties @@ -0,0 +1,74 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/project_UAS2.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=project_uas2.Project_UAS2 +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/project_UAS2/nbproject/project.xml b/project_UAS2/nbproject/project.xml new file mode 100644 index 00000000..5f1b503f --- /dev/null +++ b/project_UAS2/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + project_UAS2 + + + + + + + + + diff --git a/project_UAS2/src/projectUAS3/ProjectUASv3.java b/project_UAS2/src/projectUAS3/ProjectUASv3.java new file mode 100644 index 00000000..cdb4d321 --- /dev/null +++ b/project_UAS2/src/projectUAS3/ProjectUASv3.java @@ -0,0 +1,431 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package projectUAS3; + +/** + * + * @author USER + */ +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.*; + +class tumbuhan { + + private int urutan; + private String nama_tumbuhan; + private String kandungan; + private String manfaat; + private String bahan_bahan; + private String cara_membuat; + + public tumbuhan(int urutan, String nama_tumbuhan, String kandungan, String manfaat, String bahan_bahan, String cara_membuat) { + this.urutan = urutan; + this.kandungan = kandungan; + this.manfaat = manfaat; + this.bahan_bahan = bahan_bahan; + this.cara_membuat = cara_membuat; + this.nama_tumbuhan = nama_tumbuhan; + } + + public void displaytumbuhan() { + System.out.println(urutan + ". " + nama_tumbuhan); + } + + public void displaykandungan() { + System.out.println("==" + nama_tumbuhan + "==\n" + "KANDUNGAN " + nama_tumbuhan + kandungan + "\n" + manfaat + "\n" + bahan_bahan + "\n" + cara_membuat); + } + + public String getNamaTumbuhan() { + return nama_tumbuhan; + } + + public String getKandungan() { + return kandungan; + } + + public String getManfaat() { + return manfaat; + } + + public String getBahan_bahan() { + return bahan_bahan; + } + + public String getCaramembuat() { + return cara_membuat; + } + public int getUrurtan(){ + return urutan; + } + public int urut(){ + return urutan; + } +} + +class datatumbuhan { + + private int swapping = 0; + private tumbuhan[] tumbuh; + private tumbuhan[] tumbuh2; + private int nElemen; + + public datatumbuhan(int max) { + tumbuh = new tumbuhan[max]; + nElemen = 0; + } + + public void insert(int urutan, String nama_tumbuhan, String kandungan, String manfaat, String bahan_bahan, String cara_membuat) { + tumbuh[nElemen] = new tumbuhan(urutan, nama_tumbuhan, kandungan, manfaat, bahan_bahan, cara_membuat); + nElemen++; + } + + public String readString() { + BufferedReader a = new BufferedReader(new InputStreamReader(System.in)); + String String = ""; + try { + String = a.readLine(); + } catch (Exception e) { + System.out.println(e); + } + return String; + } + + public int readInt() { + return Integer.parseInt(readString()); + } + + public void tampilkan() { + for (int i = 0; i < nElemen; i++) { + tumbuh[i].displaytumbuhan(); + } + } + public void sorting() { + + int batas, i; + for (batas = nElemen - 1; batas > 0; batas--) { + for (i = 0; i < batas; i++) { + if (tumbuh[i].getNamaTumbuhan().compareTo(tumbuh[i + 1].getNamaTumbuhan()) > 0) { + swap(i, i + 1); + swapping++; + } + } + } + } + public void Bubblesortangka() { + + int batas, i; + for (batas = nElemen - 1; batas > 0; batas--) { + for (i = 0; i < batas; i++) { + if (tumbuh[i].urut()>tumbuh[i+1].urut()) { + swap(i, i + 1); + swapping++; + } + } + } + } + + public void swap(int one, int two) { + tumbuhan temp = tumbuh[one]; + tumbuh[one] = tumbuh[two]; + tumbuh[two] = temp; + } + + public int Totalswapping() { + return swapping; + } + + public int Totalliterasi() { + return (nElemen - 1); + } + + public int Totalperbandingan() { + return (nElemen * (nElemen - 1) / 2); + } + + public void daftar() { + int data; + int pilih; + String ulang2; + try { + do { + String ulang; + System.out.println("Selamat datang di aplikasi tanaman TOGA"); + System.out.println("1.Silahkan pilih daftar tumbuhan\n" + "2.Pencaharian berdasarkan penyakit\n" + "3.Tampilkan daftar tumbuhan setelah di sorting"); + System.out.print("Silahkan dipilih: "); + data = readInt(); + do { + if (data == 1) { +// for (int i = 0; i < nElemen; i++) { +// tumbuh[i].displaytumbuhan(); +// } +// System.out.println("apakah ingin menampilkan daftar tumbuhan secara urut dengan abjad(y/n)"); +// String ulang3 = readString(); +// if (ulang3.equals("y") || ulang3.equals("Y")) { +// urutin(); +// tampilkan(); +// } else { +// tampilkan(); +// } + Bubblesortangka(); + tampilkan(); + System.out.print("Silahkan pilih daftar tumbuhan diatas:"); + pilih = readInt(); + tumbuh[pilih - 1].displaykandungan(); + } + if (data == 2) { + System.out.println("Silahkan masukan keluhan kesehatan yang ingin anda cari"); + String nilai = readString(); + + if (nilai.equals("Batuk") || nilai.equals("batuk")) { + tumbuh[6].displaykandungan(); + System.out.println("\n\n"); + tumbuh[11].displaykandungan(); + System.out.println("\n\n"); + tumbuh[13].displaykandungan(); + System.out.println("\n\n"); + tumbuh[15].displaykandungan(); + System.out.println("\n\n"); + tumbuh[18].displaykandungan(); + System.out.println("\n\n"); + tumbuh[19].displaykandungan(); + } else if (nilai.equals("Malaria") || nilai.equals("malaria")) { + tumbuh[4].displaykandungan(); + System.out.println("\n\n"); + tumbuh[19].displaykandungan(); + } else if (nilai.equals("Diabetes") || nilai.equals("diabetes")) { + tumbuh[14].displaykandungan(); + System.out.println("\n\n"); + tumbuh[2].displaykandungan(); + System.out.println("\n\n"); + tumbuh[6].displaykandungan(); + System.out.println("\n\n"); + tumbuh[13].displaykandungan(); + System.out.println("\n\n"); + tumbuh[16].displaykandungan(); + System.out.println("\n\n"); + tumbuh[18].displaykandungan(); + } else if (nilai.equals("Darah Tinggi") || nilai.equals("darah tinggi") || nilai.equals("Hipertensi") || nilai.equals("hipertensi")) { + tumbuh[11].displaykandungan(); + System.out.println("\n\n"); + tumbuh[15].displaykandungan(); + System.out.println("\n\n"); + tumbuh[8].displaykandungan(); + System.out.println("\n\n"); + tumbuh[17].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + } else if (nilai.equals("Asma") || nilai.equals("asma")) { + tumbuh[13].displaykandungan(); + System.out.println("\n\n"); + tumbuh[15].displaykandungan(); + System.out.println("\n\n"); + tumbuh[19].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + } else if (nilai.equals("Alergi") || nilai.equals("alergi")) { + tumbuh[0].displaykandungan(); + System.out.println("\n\n"); + tumbuh[6].displaykandungan(); + } else if (nilai.equals("Komedo") || nilai.equals("komedo")) { + tumbuh[2].displaykandungan(); + } else if (nilai.equals("Gagal ginjal") || nilai.equals("gagal ginjal")) { + tumbuh[5].displaykandungan(); + } else if (nilai.equals("Sariawan") || nilai.equals("sariawan")) { + tumbuh[7].displaykandungan(); + System.out.println("\n\n"); + tumbuh[11].displaykandungan(); + } else if (nilai.equals("Kembung") || nilai.equals("kembung")) { + tumbuh[2].displaykandungan(); + System.out.println("\n\n"); + tumbuh[13].displaykandungan(); + } else if (nilai.equals("Panas dalam") || nilai.equals("panas dalam")) { + tumbuh[7].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + } else if (nilai.equals("Sembelit") || nilai.equals("sembelit")) { + tumbuh[6].displaykandungan(); + System.out.println("\n\n"); + tumbuh[15].displaykandungan(); + } else if (nilai.equals("Tumor") || nilai.equals("tumor")) { + tumbuh[18].displaykandungan(); + } else if (nilai.equals("Bronkitis") || nilai.equals("bronkitis")) { + tumbuh[18].displaykandungan(); + } else if (nilai.equals("Mata merah") || nilai.equals("mata merah")) { + tumbuh[18].displaykandungan(); + } else if (nilai.equals("Diare") || nilai.equals("diare")) { + tumbuh[1].displaykandungan(); + System.out.println("\n\n"); + tumbuh[2].displaykandungan(); + System.out.println("\n\n"); + tumbuh[5].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + System.out.println("\n\n"); + tumbuh[22].displaykandungan(); + } else if (nilai.equals("Hepatitis") || nilai.equals("hepatitis")) { + tumbuh[17].displaykandungan(); + System.out.println("\n\n"); + tumbuh[4].displaykandungan(); + System.out.println("\n\n"); + tumbuh[19].displaykandungan(); + System.out.println("\n\n"); + tumbuh[3].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + System.out.println("\n\n"); + tumbuh[21].displaykandungan(); + } else if (nilai.equals("Radang") || nilai.equals("radang")) { + tumbuh[1].displaykandungan(); + System.out.println("\n\n"); + tumbuh[11].displaykandungan(); + } else if (nilai.equals("Radang sendi") || nilai.equals("radang sendi")) { + tumbuh[3].displaykandungan(); + } else if (nilai.equals("Rematik") || nilai.equals("rematik")) { + tumbuh[0].displaykandungan(); + System.out.println("\n\n"); + tumbuh[10].displaykandungan(); + System.out.println("\n\n"); + tumbuh[12].displaykandungan(); + System.out.println("\n\n"); + tumbuh[14].displaykandungan(); + System.out.println("\n\n"); + tumbuh[24].displaykandungan(); + } else if (nilai.equals("Wasir") || nilai.equals("wasir")) { + tumbuh[9].displaykandungan(); + System.out.println("\n\n"); + tumbuh[21].displaykandungan(); + System.out.println("\n\n"); + tumbuh[22].displaykandungan(); + } else if (nilai.equals("Anemia") || nilai.equals("anemia")) { + tumbuh[15].displaykandungan(); + System.out.println("\n\n"); + tumbuh[16].displaykandungan(); + } else if (nilai.equals("Kanker") || nilai.equals("kanker")) { + tumbuh[0].displaykandungan(); + System.out.println("\n\n"); + tumbuh[3].displaykandungan(); + System.out.println("\n\n"); + tumbuh[5].displaykandungan(); + System.out.println("\n\n"); + tumbuh[8].displaykandungan(); + System.out.println("\n\n"); + tumbuh[11].displaykandungan(); + System.out.println("\n\n"); + tumbuh[15].displaykandungan(); + } else if (nilai.equals("Jantung") || nilai.equals("jantung")) { + tumbuh[14].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + } else if (nilai.equals("Stroke") || nilai.equals("stroke")) { + tumbuh[13].displaykandungan(); + } else if (nilai.equals("Demam") || nilai.equals("demam")) { + tumbuh[4].displaykandungan(); + System.out.println("\n\n"); + tumbuh[7].displaykandungan(); + System.out.println("\n\n"); + tumbuh[8].displaykandungan(); + System.out.println("\n\n"); + tumbuh[12].displaykandungan(); + System.out.println("\n\n"); + tumbuh[13].displaykandungan(); + System.out.println("\n\n"); + tumbuh[16].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + System.out.println("\n\n"); + tumbuh[24].displaykandungan(); + } else if (nilai.equals("Keputihan") || nilai.equals("keputihan")) { + tumbuh[10].displaykandungan(); + } else if (nilai.equals("TBC") || nilai.equals("tbc")) { + tumbuh[10].displaykandungan(); + } else if (nilai.equals("Sakit gigi") || nilai.equals("sakit gigi")) { + tumbuh[4].displaykandungan(); + } else if (nilai.equals("Maag") || nilai.equals("maag")) { + tumbuh[1].displaykandungan(); + } else if (nilai.equals("Kencing batu") || nilai.equals("kencing batu")) { + tumbuh[21].displaykandungan(); + } else if (nilai.equals("Asam urat") || nilai.equals("asam urat")) { + tumbuh[21].displaykandungan(); + } else if (nilai.equals("Radang gusi") || nilai.equals("radang gusi")) { + tumbuh[22].displaykandungan(); + } else if (nilai.equals("Cacingan") || nilai.equals("cacingan")) { + tumbuh[16].displaykandungan(); + tumbuh[23].displaykandungan(); + } else if (nilai.equals("Sakit perut") || nilai.equals("sakit perut")) { + tumbuh[8].displaykandungan(); + tumbuh[23].displaykandungan(); + } else if (nilai.equals("Cacar air") || nilai.equals("cacar air")) { + tumbuh[23].displaykandungan(); + } else if (nilai.equals("Bau mulut") || nilai.equals("bau mulut")) { + tumbuh[24].displaykandungan(); + } else if (nilai.equals("Batu ginjal") || nilai.equals("batu ginjal")) { + tumbuh[24].displaykandungan(); + } else { + System.out.println("TIDAK ADA DI DAFTAR PENCAHARIAN"); + } + } + if (data == 3) { + sorting(); + tampilkan(); + System.out.println("\nTotal Perpindahan: "+Totalswapping()); + System.out.println("Total literasi: "+Totalliterasi()); + System.out.println("Total perbandingan: "+Totalperbandingan()); + System.out.print("Silahkan pilih daftar tumbuhan diatas:"); + Bubblesortangka(); + pilih = readInt(); + tumbuh[pilih-1].displaykandungan(); + } + System.out.println("apakah anda ingin kembali lagi?y/n"); + ulang = readString(); + + } while (ulang.equals("y") || ulang.equals("Y")); + System.out.println("apakah anda mau kembali ke home?y/n"); + ulang2 = readString(); + } while (ulang2.equals("y") || ulang2.equals("Y")); + System.out.println(">>>>>>>>>>>>>>>TERIMA KASIH<<<<<<<<<<<<<<<"); + System.out.println("Semoga sehat selalu"); + System.out.println("Copyright Galuh Muhammad Iman Akbar"); + } catch (Exception e) { + System.out.println("Masukan inputan dengan benar"); + System.out.println(""); + daftar(); + } + } +} + +public class ProjectUASv3 { + + public static void main(String[] args) { + datatumbuhan panggil = new datatumbuhan(25); + panggil.insert(1, "JAHE", "\n1.Minyak atsiri zingiberena (zingirona)\n2.zingiberol\n3.kurkumen\n4.gingerol\n5.filandrena\n6.resin pahit\n7.bisabolena", "MANFAAT:\n1.Menghangatkan badan\n2.menuruntkan berat badan\n3.menjaga kondisi jantung\n4.mengatasi mabuk perjalanan\n5.mengatasi gangguan pencernaan\n6.mencegah kanker usus\n7.mengobati sakit kepala\n8.mengomati alergi\n9.mengobati penyakit rematik\n10.meningkatkan sistem kekebalan tubuh", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT WEDANG JAHE:\n1.Jahe\n2.Gula pasir atau gula merah(Sesuai selera)\n3.Air", "CARA MEMBUAT WEDANG JAHE:\n1.kupas dan cuci jahe hingga bersih\n2.Rebus air hingga mendidih\n3.Sembari menunggu air mendidih, jahe dibakar sampai kemerah-merahan\n4.Kupas bagian yang terbakar\n5.Potong kecil-kecil dan dipukul agar aromanya keluar\n6.Masukan jahe yang telah di pukul ke dalam gelas\n7. Masukan gula secukupnya kedalam gelas\n8.Tuangkan air yang sudah dimasak tadi aduk hingga rata\n9.Hidangkan saat masih panas"); + panggil.insert(2, "KUNYIT", "\n1.kurkumin\n2.desmetoksikumin\n3.bisdesmetoksikurkumin\n4.Keton sesquiterpen\n5.turmeron\n6.Zingiberen", "MANFAAT:\n1.Sebagai ramuan anti peradangan tubuh\n2.Mengobati penyakit asam lambung\n3.Mengurangi gas pada pencernaan\n4.Meredakan sakit akibat irritable bowel syndrom\n5.Mengurangi mual\n6.Meredakan diare", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT JAMU KUNYIT:\n1.Empat gelas air\n2.Satu sendok teh kunyit parutan kunyit\n3.Lemon atau madu untuk ditambahkan pada tahap akhir", "CARA MEMBUAT JAMU KUNYIT:\n1.Rebus 4 gelas air sampai mendidih\n2.Masukkan 1 sendok teh kunyit ke air yang sedang mendidih\n3.Kecilkan api dan biarkan air yang sudah dicampur kunyit tersebut mendidih selama sekitar 10 menit\n4.Matikan api dan saring air kunyit tersebut menggunakan saringan yang halus\n5.Tuangkan hasil saringan tersebut ke dalam gelas dan tambahkan lemon atau madu sesuai selera"); + panggil.insert(3, "DAUN JAMBU BIJI", "\n1.Saponin\n2.Flavanoid\n3.Polifenol\n4.Alkaloid\n5.Karoten\n6.Steroid\n7.Kuinon\n8.Anti-oksidan\n9.Minyak atsiri\n10.Tannin\n11.Senyawa anti-mutagenic", "MANFAAT:\n1.Mengobati diare dan disentri\n2.Diabetes Mellitus\n3.Mengobati Luka Memar\n4.Mengatasi Jerawat\n5.Mengatasi Komedo\n6.Ambeien\n7.Mengusir kembung", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN JAMBU BIJI:\n1.Siapkan 7-10 lembar daun jambu biji\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN JAMBU BIJI:\n1.Cuci bersih daun tersebut dalam air yang mengalir\n2.Rebus 2-3 gelas air minum, setelah mendidih masukan daun jambu biji terlebus\n3.Rebus hingga air tersisa setengahnya sambil sesekali di aduk\n4.Setelah dingin ramuan air rebusan siap untuk di minum"); + panggil.insert(4, "TEMULAWAK", "\n1.Magnesium\n2.Phosphorus\n3.Zinc\n4.Asam folat\n5.Vitamin A\n6.Vitamin D", "MANFAAT:\n1.Memelihara Fungsi Hati\n2.Mengurangi radang sendi\n3.Masalah pencernaan\n4.Membantu Menurunkan Lemak Darah\n5.Melawan Kanker", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT JAMU TEMULAWAK:\n1.satu jari, rimpang temulawak iris-iris\n2.Sepuluh lembar, daun ungu\n3.Sstu gelas air putih 200ml", "CARA MEMBUAT JAMU TEMULAWAK:\n1.Bersihkan rimpang temulawak dengan daun ungu hingga bersih\n2.Setelah itu, rebus kedua bahan tersebut hingga mendidih\n3.Kemudian, angkat dan dinginkan lalu sharing\n4.Minum ramuan tersebut secara rutin 2 kali sehari sebanyak setengah gelas"); + panggil.insert(5, "SAMBILOTO", "\n1.Andrographolide\n2.Saponin\n3.Falvonoid\n4.Alkanoid\n5.Tanin\n6.Laktone\n7.Panikulin\n8.Kalmegin\n9.Hablur kuning", "MANFAAT:\n1.Dapat mengobati hepatitis\n2.Mengobati disentri basiler\n3.Mengobati sakit gigi\n4.Mengobati demam\n5.Mengobati Malaria", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN SAMBILOTO:\n1.Daun sambiloto\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN SAMBILOTO:\n1.Daun sambiloto segar sebanyak satu genggam\n2.Ditumbuk rata kemudian ditambahkan air matang sebanyak 110mL\n3.Saring kemudian minum sekaligus"); + panggil.insert(6, "KIJIBELING", ":\n1.Tripenoid\n2.Fosfor\n3.Natrium\n4.Kafein\n5.Kalsium\n6.Asam silikat\n7.Potassium", "MANFAAT:\n1.Menjaga kesehatan ginjal\n2.Diuretic alami\n3.Meningkatkan volume darah\n4.Mempercepat proses pembekuan darah\n5.Menghambat pertumbuhan kanker\n6.Mengatasi diare serta disentri\n7.Menjaga kesehatan organ hati\n8.Menurunkan kolestrol", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN KIJIBELING:\n1.Siapkan daun kijibeling sekitar 5-6 lembar\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN KIJIBELING:\n1.Rebus air bersamaan dengan daun kijibeling\n2.Tunggu hingga air setengah\n3.Setelah itu, angkat dan dinginkan\n4.Setelah dingin, minum ramuan tersebut dua kali sehari"); + panggil.insert(7, "KUMIS KUCING", ":\n1.Garam kalium\n2.Glikosida Orthosiphonim\n3.Mioinositol\n4.Minyak Atsiri\n5.Saponin\n6.Sapofonim\n7.Sinensetis\n8.Zat samak", "MANFAAT:\n1.Melancarkan air seni\n2.Mengobati batuk\n3.Mengobati sembelit\n4.Mengobati diabetes\n5.Mengobati gatal karena alergi", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN TUMBUHAN KUMIS KUCING:\n1.Siapkan 90 gr daun kumis kucing segar\n2.Satu gelas air putih", "CARA MEMBUAT AIR SEDUHAN DAUN TUMBUHAN KUMIS KUCING:\n1.Cuci daun kumis kucing sampai bersih\n2.Rebus daun kumis kucing tersebut dengan air hingga airnya tersisa 1/2 gelas saja\n3.Minum ramuan tersebut sebanyak 3x sehari dengan dosis 1/2 gelas"); + panggil.insert(8, "PEGAGAN", ":\n1.brahmoside\n2.brahmic acid\n3.brahminosid\n4.asiaticoside\n5.madecassoside\n6.madasiatic acid\n7.centelloside", "MANFAAT:\n1.Mengobati sariawan dan panas dalam\n2.Menghilangkan jerawat dan menghaluskan wajah\n3.Sebagai pembersih alami\n4.Melancarkan sirkulasi darah\n5.Menurunkan demam\n6.Meningkatkan tenaga dan stamina tubuh\n7.Meningkatkan sistem saraf ingatan", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN PEGAGAN\n1.Satu genggam daun pegagan\n2.Lima batang tapak lima\n3.Setengah genggam, daun jintan hitam\n4. Satu sendok madu\n5. Satu gelas air putih 200mL ", "CARA MEMBUAT SEDUHAN DAUN PEGAGAN:\n1.Cuci bersih semua bahan, lalu masukan dalam panci bersama satu gelas air\n2.Setelah itu rebus hingga mendidih\n3.Selanjutnya saring ainya dan beri campuran madu, aduk sampai rata\n4.Angkat dan minum air ramuan tersebut secara rutin sehari 2 kali pagi dan sore"); + panggil.insert(9, "CINCAU", ":\n1.Serat Makanan\n2.Fosfor\n3.Vitamin A\n4.Vitamin B1\n5.Vitamin C\n6.Protein\n7.Lemak\n8.Karbohidrat\n9.Energi", "MANFAAT:\n1.Mengobati sakit perut dan tekanan darah tinggi\n2.Mengobati demam\n3.Mengobati penyakit kanker", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT CINCAU:\n1.Air matang 300 mL\n2.Daun cincau 40 lembar yang sedang, cuci bersih", "CARA MEMBUAT CINCAU:\n1.Petama-tama remas-remas daun cincau segar\n2.Tuanglah 1/2 bagian air sedikit demi sedikit sambil terus diremas-remas sampai keluar lendir/gel berwarna hijau\n3.Selanjutnya saring remasan daun cincau\n4.Kemudian remas-remas kembali ampas (daun cincau) sambil tuang sisa air sampai keluar lendirnya. Setelah itu saring\n5.Nah sekarang simpan hasil saringan daun cincau dalam lemari pendingin sampai beku selama kurang lebih 3-4 jam\n6.Cincau hijau siap digunakan, bisa diolah lanjutan menjadi es cincau segar"); + panggil.insert(10, "LIDAH BUAYA", "\n1.Energi\n2.Protein\n3.Karbohidrat\n4.Kalsium\n5.Zat besi\n6.Vitamin A\n7.Vitamin B\n8.Vitamin C\n8.Fosfor", "MANFAAT:\n1.Penyubur rambut\n2.Sebagai anti oksidan\n3.Menghilangkan ketombe\n4.Detoksifikasi\n5.Menjaga kesehatan mulut\n6.Menjaga berat badan\n7.Mengobati wasir\n8.Menghilangkan jerawat", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT NATA DE ALOE VERA:\n1.Daun lidah buaya\n2.Garam\n3.Air", "CARA MEMBUAT NATA DE ALOE VERA:\n1.Daun lidah buaya dipotong sekitar per 10 cm menjadi 5 potong\n2.Hilangkan kulit yang berwarna hijau, tinggalkan dagaing ynag berwarna bening\n3.Dari potongan memanjang potong lagi menjadi kotak-kotak seperti nata de coco\n4.Kemudian cuci berulang-ulang sampai lendirnya habis\n5.Tambahkan garam dalam pencucian mungkin 2 sampai 3 kali saat membilasnya\n6.Kemudian rebuslah, tunggu 15 menit selama mendidih, setelah itu angkat, untuk mengurangi bau dapat ditambahkan daun pandan"); + panggil.insert(11, "BLUNTAS", "\n1.Alkanoid\n2.Pluchine\n3.Asam kafeoilkuniat\n4.Saponin\n5.polifenol\n6.Tannin\n7.Asam amino\n8.Kalsium\n9.Fosfor\n10.Vitamin A\n11.Vitamin C", "MANFAAT:\n1.Mengobati pencernaan pada anak-anak\n2.Mengatasi TBC kelenjar leher\n3.Mengatasi nyeri rematik\n4.Menghilangkan bau badan dan bau mulut\n5.Obat keputihan\n6.Mengatasi masalah hipertensi\n7.Melancarkan haid", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN BELUNTAS:\n1.Siapkan beberapa helai daun beluntas 3-5 lembar\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN BELUNTAS:\n1.Cuci daun beluntas sampai benar-benar bersih, kemudian rebus dengan 2 gelas air bersih\n2.Tunggu sampai mendidih hingga tersisa 1 gelas\n3.Angkat dan kemudian diamkan sampai menjadi hangat, minumlah secara rutin pagi dan sore hari"); + panggil.insert(12, "BELIMBING WULUH", "\n1.Glukosid\n2.Tanin\n3.Asam folat\n4.Peroksida\n5.Kalsium oksalat\n6.Sulfur\n7.Kalium sitrat", "MANFAAT:\n1.Obat sariawan dan mengatasi gusi berdarah\n2.Melancarkan pencernaan\n3.Menghaluskan kulit wajah\n4.Menyembuhkan batuk\n5.Menyembuhkan gondongan\n6.Mencegah penyakit kanker\n7.Mengatasi hipertensi\n8.Mengatasi rematik", "BAHAN-BAHAN YANG DIPERLUKAN BUAT SIRUP BELIMBING WULUH:\n1.200 gram belimbing wuluh yang segar dan sudah dicuci\n2. Satu setengah air putih\n3.Madu secukupnya\n4.Es batu secukupnya", "CARA MEMBUAT SIRUP BELIMBING WULUH:\n1.Potong kecil-kecil buah belimbing wuluh\n2.Masukan semua bahan ke dalam bender, lalu bender hingga halus\n3.Tuang jus kedalam gelas saji\n4.Jus belimbing siap untuk disajikan"); + panggil.insert(13, "BROTOWALI", "\n1.Glikosida pikroretosid\n2.Harsa\n3.Berberin\n4.Palmatin\n5.Alkaloid berberin", "MANFAAT:\n1.Mengobati rematik\n2.Mengobati demam kuning\n3.Mengobati diabetes\n4.Mengobati kudis\n5.Mengobati luka", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN AIR BROTOWALI:\n1.6cm batang brotowali\n2.Sepertiga genggam daun kumis kucing\n3.Sepertiga daun sambiloto\n4.Tiga gelas air", "CARA MEMBUAT SEDUAN AIR BROTOWALI:\n1.Cuci bersih dan potong-potong semua herba\n2.Rebuslah semua herba dengan 3 gelas air hingga mendidih dan tersisa 2 gelas air\n3.Setelah dingin, saring dan minum 1 gelas setelah makan 2 kali sehari"); + panggil.insert(14, "DAUN JINTEN", "\n1.Minyak atsiri\n2.Fenol\n3.Kalium", "MANFAAT:\n1.Mengembalikan kekebalan tubuh\n2.Obat demam\n3.Mengobati asma\n4.Sebagai obat batuk\n5.Mengobati penyakit stroke\n6.Mengobati rematik\n7.Mengobati perut kembung", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN JINTEN:\n1.Siapkan 6 lembar daun jinten\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN JINTEN:\n1.Cuci bersih daun jinten kemudian tumbuklah sampai halus\n2.Rebuslah air hingga mendidih\n3.Setelah air mendidih angkat kemudian tuangkan air ke dalam gelas yang sudah berisi daun jinten\n4.Air seduhan daun jinten siap dihidangkan"); + panggil.insert(15, "KAYU MANIS", "\n1.Eugenol\n2.Minyak atsiri\n3.tanin\n4.Sinamaldehide\n5.Kalsium oksalat\n6.Safrole\n7.Zat penyamak dan damar", "MANFAAT:\n1.Mengurangi rasa nyeri haid\n2.Mencegah terjadinya penggumpalan darah\n3.Mengurangi sakit rematik\n4.Mencegah penyakit jantung\n5.Menghangatkan tubuh\n6.Mengontrol gula darah", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT:\n1.Siapkan 1 batang kayu manis\n2.Madu\n3.Air secukupnya", "CARA MEMBUAT AIR SEDUHAN KAYU MANIS:\n1.Rebuslah air selama kurang lebih 5 menit\n2.Kemudian masukan kayu manis ke dalam air yang direbus\n3.Setelah itu tuangkan ke dalam gelas\n4.Tambahkan madu supaya lebih nikmat\n5.Air seduhan kayu manis siap dihidangkan"); + panggil.insert(16, "SELEDRI", "\n1.Kalium\n2.Folat\n3.Kalsium\n4.Vitamin K\n5.Serat", "MANFAAT:\n1.Mengobati rematik\n2.Mengobati anemia\n3.Mengobati batuk\n4.Memerangi kanker\n5.Menurunkan tekanan darah tinggi\n6.Mencegah asma\n7.Mencegah sembelit", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN SELEDRI:\n1.Daun seledri\n2.Air 3 gelas", "CARA MEMBUAT AIR SEDUHAN SELEDRI:\n1.Saipkan daun seledri\n2.Cuci hingga bersih\n3.Kemudian potong-potong\n4.Tuangkan 3 gelas kedalam panci\n5.Masukan daun seledri\n6.Tunggu airnya hingga menjadi 1 gelas:\n7.Air seduhan seledri siap diminum"); + panggil.insert(17, "DAUN KELOR", "\n1.Protein\n2.Fosfor\n3.Zat besi\n4.Kalsium\n5.Vitamin B1\n6.Vitamin C\n7.Vitamin A", "MANFAAT:\n1.Antimikroba\n2.Mencegah rematik\n3.Mengobati demam\n4.Mengobati anemia\n5.Mengobati diabetes\n6.Mengobati cacingan", "BAHAN-BAHAN YANG DIPERLUKAN UTNUK MEMBUAT TEH DAUN KELOR:\n1.Daun kelor yang sudah di keringkan\n2.Air secukupnya\n3.Madu", "CARA MEMBUAT TEH DAUN KELOR:\n1.Siapkan daun kelor yang sudah di keringkan\n2.Rebus air hingga mendidih\n3.Kemudian masukan air ke dalam gelas yang sudah berisi daun kelor\n4.Setelah itu saring daun kelor tersebut\n5.Air teh daun kelor siap dihidangkan"); + panggil.insert(18, "DAUN MURBEI", "\n1.Eugenol\n2.Betahexenal\n3.Benzaidehide\n4.Vitamin A\n5.Vitamin B1\n6.Vitamin C\n7.Karoten", "MANFAAT:\n1.Mengobati tekanan darah tinggi\n2.Mengobati rematik\n3.Mengobati hepatitis kronis\n4.Menggobati gigitan ular\n5.Mengobati jantung lemah", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT TEH MURBEI:\n1.Pucuk daun teh murbei yang sudah kering\n2.Air secukup nya", "CARA MEMBUAT TEH MURBEI:\n1.Siapkan pucuk daun teh murbei yang sudah di keringkan\n2.Rebus air hingga mendidih\n3.Tuangkan air kedalam gelas yang sudah berisi daun murbei\n4.Kemudian saring, dan teh daun murbei sudah siap diminum"); + panggil.insert(19, "SIRIH MERAH", "\n1.Allyprokatekol\n2.Alkaloid\n3.Cineole\n4.Extragol\n5.Eugenol\n6.F enil propoda\n7.Minyak atsiri", "MANFAAT:\n1.Mengobati Mata merah\n2.Mengobati gusi berdarah\n3.Mengobati penyakit bronkitis\n4.Mengobati darah tinggi\n5.Mengobati batuk\n6.Mengobati tumor\n7.Mengobati diabetes", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN DAUN SIRIH MERAH:\n1.Sirih merah secukupnya\n2.Air secukupnya", "CARA MEMBUAT SEDUHAN DAUN SIRIH MERAH:\n1.Siapkan sirih merah\n2.Rebus Air hingga mendidih\n3.Kemudain masukan sirih merah ke dalam air mendidih\n4.Saring air seduhan sirih merah dan tuangkan ke dalam gelas\n5.Air seduhan sirih merah siap diminum"); + panggil.insert(20, "DAUN ASAM", "\n1.Flavanoid\n2.Asam askorbat\n3.Tanin\n4.Vitamin C", "MANFAAT:\n1.Sebagai obat asma\n2.Sebagai obat batuk kering\n3.Mengobati malaria\n4.Menyembuhkan peradangan\n5.Mencegah penyakit kuning", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN DAUN ASAM:\n1.Segenggam daun asam\n2.Lima ruas kunyit\n3.Air secukupnya", "CARA MEMBUAT SEDUHAN DAUN ASAM:\n1.Tumbuk 1 genggam daun asam dan 5 ruas kunyit\n2.Rebus dengan air 300 cc hinggan menjadi 200 cc\n3.Kemudian tuangkan kedalam gelas\n4.Supaya lebih nikmat tambahkan gula aren secukupnya\n5.Diamkan hingga dingin lalu minum"); + panggil.insert(21, "ALANG-ALANG", "\n1.Silindrin\n2.Isoarbolinol\n3.Simiarenol\n4.Fernenol\n5.Arun doin\n6.Asam klorogenat\n7.Katekol\n8.Asam Isoklorogenat\n9.Asam oksalat\n1 0.Asam asetat\n11.Asam sitrat", "MANFAAT:\n1.Sebagai obat asma\n2.Mengobati hepatitis\n3.Mengobati diare\n4.Penyakit jantung\n5.Infeksi ginjal\n6.Demam\n7.Hipertensi", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN ALANG-ALANG:\n1.Air mineral 2 gelas\n2.Alang-alang secukupnya", "CARA MEMBUAT SEDUHAN ALANG-ALANG:\n1.Siapkan alang-alang secukupnya\n2.Cuci terlebih dulu alang-alang hingga bersih\n3.Potong kecil alang-alang\n4.Rebus hingga mendidih\n5.Terakhir angkat, diinginkan dan saring ampasnya\n6.Air rebusan alang-alang siap diminum"); + panggil.insert(22, "DAUN TEMPUYUNG", "\n1.Flavanoid\n2.Taraksasterol\n3.Inositol\n4.Kumarin\n5.Asam fenolat", "MANFAAT:\n1.Mengobati kencing batu\n2.Mengobati asam urat\n3.Mengobati wasir\n4.Mengobati wasir", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN DAUN TEMPUYUNG:\n1.Air mineral\n2.Daun tempuyung secukupnya", "CARA MEMBUAT SEDUHAN DAUN TEMPUYUNG:\n1.Siapkan daun tempuyung yang masih segar\n2.Cuci terlebih dahulu hingga bersih\n3.Seduh hingga medidih\n4.Saring dan kemudian dinginkan\n5.Air daun tempuyung siap diminum"); + panggil.insert(23, "DAUN ANDONG", "\n1.Saponin\n2.Tanin\n3.Flavonoid\n4.Polifenol\n5.Steroida\n6.Kalsium oksalat\n7.Zat besi", "MANFAAT:\n1.Mengobati radang gusi\n2.Mengobati diare\n3.Mengobati wasir", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT DAUN TEMPUYUNG:\n1.Air mineral\n2.Daun andong secukupnya", "CARA MEMBUAT SEDUHAN DAUN ANDONG:\n1.Siapkan daun andong yang masih segar\n2.Cuci hingga bersih\n3.Masukan daun andong kemudian rebus hingga mendidih\n4.Saring daun andong dan dinginkan\n5.Air daun andong siap untuk diminum"); + panggil.insert(24, "TEMU GIRING", "\n1.Tannin\n2.Minyak atsiri\n3.Flavonoida\n4.Piperazin sitrat\n5.Damar\n6.Kurkumin\n7.Protein\n8.Lemak", "MANFAAT:\n1.Mengobati cacingan\n2.Obat sakit perut\n3.Mengobati cacar air\n4.Mengobati kudis", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT JAMU TEMU GIRING:\n1.Air mineral\n2.Temu giring\n3.Madu", "CARA MEMBUAT JAMU TEMU GIRING:\n1.Cuci temu giring hingga bersih\n2.Parut temu ginring hingga halus\n3.Masukan hasil arutan kedalam gelas\n4.Rebus air hingga mendidih\n5.Tuangkan air ke dalam gelas yang berisi hasil parutan temu giring\n6.Saring dan tambahkan madu supaya lebih nikmat\n7.Jamu temu giring siap diminum"); + panggil.insert(25, "AKAR WANGI", "\n1.Senyawa karbonil\n2.Ester\n3.Vetiveron\n4.Seskuiterpen\n5.Seskuiterpen derivatif", "MANFAAT:\n1.Mengatasi bau mulut\n2.Mengobati rematik\n3.Mengobati batu ginjal\n4.Menurunkan demam", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN AKAR WANGI:\n1.Akar wangi secukupnya\n2.Air secukupnya\n3.Garam", "CARA MEMBUAT SEDUHAN AKAR WANGI:\n1.Cuci terlebih dahulu akar wangi\n2.Potong-potong akar wangi, rebus dengan air sampai mendidih\n3.Masukan garam secukupnya\n4.Tunggu hingga air mengeluarkan wangi\n5.Tuangkan air di gelas tunggu hingga hangat\n6.Air akar wangi siap untuk diminum"); + panggil.daftar(); + } +} diff --git a/project_UAS2/src/projectUAS3/ProjectUASv3Insertion.java b/project_UAS2/src/projectUAS3/ProjectUASv3Insertion.java new file mode 100644 index 00000000..6bde8ca4 --- /dev/null +++ b/project_UAS2/src/projectUAS3/ProjectUASv3Insertion.java @@ -0,0 +1,444 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package projectUAS3; + +/** + * + * @author USER + */ +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.*; + +class tumbuhan1 { + + private int urutan; + public String nama_tumbuhan; + private String kandungan; + private String manfaat; + private String bahan_bahan; + private String cara_membuat; + private int swapping=0; + + public tumbuhan1(int urutan, String nama_tumbuhan, String kandungan, String manfaat, String bahan_bahan, String cara_membuat) { + this.urutan = urutan; + this.kandungan = kandungan; + this.manfaat = manfaat; + this.bahan_bahan = bahan_bahan; + this.cara_membuat = cara_membuat; + this.nama_tumbuhan = nama_tumbuhan; + } + + public void displaytumbuhan() { + System.out.println(urutan + ". " + nama_tumbuhan); + } + + public void displaykandungan() { + System.out.println("==" + nama_tumbuhan + "==\n" + "KANDUNGAN " + nama_tumbuhan + kandungan + "\n" + manfaat + "\n" + bahan_bahan + "\n" + cara_membuat); + } + + public String getNamaTumbuhan() { + return nama_tumbuhan; + } + + public String getKandungan() { + return kandungan; + } + + public String getManfaat() { + return manfaat; + } + + public String getBahan_bahan() { + return bahan_bahan; + } + + public String getCaramembuat() { + return cara_membuat; + } + public int TotalComparing(int n) { + + if (n == 1) { + return 1; + } else { + return n + TotalComparing(n - 1); + } + } + + public int swapping(){ + return swapping; + } +} + +class datatumbuhan1 { + + private tumbuhan1[] tumbuh; + private tumbuhan1[] tumbuh2; + private int nElemen; + + public datatumbuhan1(int max) { + tumbuh = new tumbuhan1[max]; + nElemen = 0; + } + + public void insert(int urutan, String nama_tumbuhan, String kandungan, String manfaat, String bahan_bahan, String cara_membuat) { + tumbuh[nElemen] = new tumbuhan1(urutan, nama_tumbuhan, kandungan, manfaat, bahan_bahan, cara_membuat); + nElemen++; + } + + + public String readString() { + BufferedReader a = new BufferedReader(new InputStreamReader(System.in)); + String String = ""; + try { + String = a.readLine(); + } catch (Exception e) { + System.out.println(e); + } + return String; + } + + public int readInt() { + return Integer.parseInt(readString()); + } + + public void tampilkan() { + for (int i = 0; i < nElemen; i++) { + tumbuh[i].displaytumbuhan(); + } + } + + public void tampilkan2(tumbuhan1 tumbuh1[]) { + for (int i = 0; i < nElemen; i++) { + tumbuh1[i].displaytumbuhan(); + } + } + public void copy(){ + for (int i = 0; i < tumbuh.length; i++) { + tumbuh2[i]=tumbuh[i]; + } + } + + public void Bubblesort() { + int batas, i; + for (batas = nElemen - 1; batas > 0; batas--) { + for (i = 0; i < batas; i++) { + if (tumbuh[i].nama_tumbuhan.compareTo(tumbuh[i + 1].nama_tumbuhan) > 0) { + swap(i, i + 1); + + } + } + } + } + public void InsertionSort(){ + int i, curln; + for (curln = 1; curln < nElemen; curln++) { + tumbuhan1 temp=tumbuh[curln]; + + i=curln; + while(i > 0 && tumbuh[i-1].nama_tumbuhan.compareTo(temp.nama_tumbuhan)>=0){ + tumbuh[i]=tumbuh[i-1]; + i--; + } + tumbuh[i]=temp; + } + } + public tumbuhan1[] SelectionSort(tumbuhan1[] arr){ + tumbuhan1[] tumb= arr; + int awal,i,min; + for (awal = 0; awal < nElemen-1; awal++) { + min=awal; + for (i = awal+1; i < nElemen; i++) { + if (tumb[i].nama_tumbuhan.compareTo(tumb[min].nama_tumbuhan)<0) { + min=i; + } + } + + swap(awal,min); + } + return tumb; + } + + public void swap(int one, int two) { + tumbuhan1 temp = tumbuh[one]; + tumbuh[one] = tumbuh[two]; + tumbuh[two] = temp; + } + + public void daftar() { + int data; + int pilih; + String ulang2; + try { + do { + String ulang; + System.out.println("Selamat datang di aplikasi tanaman TOGA"); + System.out.println("1.Silahkan pilih daftar tumbuhan\n" + "2.Pencaharian berdasarkan penyakit\n" + "3.Sorting berdasarkan abjad"); + System.out.print("Silahkan dipilih: "); + data = readInt(); + do { + if (data == 1) { + tampilkan(); + + System.out.print("Silahkan pilih daftar tumbuhan diatas:"); + pilih = readInt(); + tumbuh[pilih - 1].displaykandungan(); + } + if (data == 2) { + System.out.println("Silahkan masukan keluhan kesehatan yang ingin anda cari"); + String nilai = readString(); + + if (nilai.equals("Batuk") || nilai.equals("batuk")) { + tumbuh[6].displaykandungan(); + System.out.println("\n\n"); + tumbuh[11].displaykandungan(); + System.out.println("\n\n"); + tumbuh[13].displaykandungan(); + System.out.println("\n\n"); + tumbuh[15].displaykandungan(); + System.out.println("\n\n"); + tumbuh[18].displaykandungan(); + System.out.println("\n\n"); + tumbuh[19].displaykandungan(); + } else if (nilai.equals("Malaria") || nilai.equals("malaria")) { + tumbuh[4].displaykandungan(); + System.out.println("\n\n"); + tumbuh[19].displaykandungan(); + } else if (nilai.equals("Diabetes") || nilai.equals("diabetes")) { + tumbuh[14].displaykandungan(); + System.out.println("\n\n"); + tumbuh[2].displaykandungan(); + System.out.println("\n\n"); + tumbuh[6].displaykandungan(); + System.out.println("\n\n"); + tumbuh[13].displaykandungan(); + System.out.println("\n\n"); + tumbuh[16].displaykandungan(); + System.out.println("\n\n"); + tumbuh[18].displaykandungan(); + } else if (nilai.equals("Darah Tinggi") || nilai.equals("darah tinggi") || nilai.equals("Hipertensi") || nilai.equals("hipertensi")) { + tumbuh[11].displaykandungan(); + System.out.println("\n\n"); + tumbuh[15].displaykandungan(); + System.out.println("\n\n"); + tumbuh[8].displaykandungan(); + System.out.println("\n\n"); + tumbuh[17].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + } else if (nilai.equals("Asma") || nilai.equals("asma")) { + tumbuh[13].displaykandungan(); + System.out.println("\n\n"); + tumbuh[15].displaykandungan(); + System.out.println("\n\n"); + tumbuh[19].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + } else if (nilai.equals("Alergi") || nilai.equals("alergi")) { + tumbuh[0].displaykandungan(); + System.out.println("\n\n"); + tumbuh[6].displaykandungan(); + } else if (nilai.equals("Komedo") || nilai.equals("komedo")) { + tumbuh[2].displaykandungan(); + } else if (nilai.equals("Gagal ginjal") || nilai.equals("gagal ginjal")) { + tumbuh[5].displaykandungan(); + } else if (nilai.equals("Sariawan") || nilai.equals("sariawan")) { + tumbuh[7].displaykandungan(); + System.out.println("\n\n"); + tumbuh[11].displaykandungan(); + } else if (nilai.equals("Kembung") || nilai.equals("kembung")) { + tumbuh[2].displaykandungan(); + System.out.println("\n\n"); + tumbuh[13].displaykandungan(); + } else if (nilai.equals("Panas dalam") || nilai.equals("panas dalam")) { + tumbuh[7].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + } else if (nilai.equals("Sembelit") || nilai.equals("sembelit")) { + tumbuh[6].displaykandungan(); + System.out.println("\n\n"); + tumbuh[15].displaykandungan(); + } else if (nilai.equals("Tumor") || nilai.equals("tumor")) { + tumbuh[18].displaykandungan(); + } else if (nilai.equals("Bronkitis") || nilai.equals("bronkitis")) { + tumbuh[18].displaykandungan(); + } else if (nilai.equals("Mata merah") || nilai.equals("mata merah")) { + tumbuh[18].displaykandungan(); + } else if (nilai.equals("Diare") || nilai.equals("diare")) { + tumbuh[1].displaykandungan(); + System.out.println("\n\n"); + tumbuh[2].displaykandungan(); + System.out.println("\n\n"); + tumbuh[5].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + System.out.println("\n\n"); + tumbuh[22].displaykandungan(); + } else if (nilai.equals("Hepatitis") || nilai.equals("hepatitis")) { + tumbuh[17].displaykandungan(); + System.out.println("\n\n"); + tumbuh[4].displaykandungan(); + System.out.println("\n\n"); + tumbuh[19].displaykandungan(); + System.out.println("\n\n"); + tumbuh[3].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + System.out.println("\n\n"); + tumbuh[21].displaykandungan(); + } else if (nilai.equals("Radang") || nilai.equals("radang")) { + tumbuh[1].displaykandungan(); + System.out.println("\n\n"); + tumbuh[11].displaykandungan(); + } else if (nilai.equals("Radang sendi") || nilai.equals("radang sendi")) { + tumbuh[3].displaykandungan(); + } else if (nilai.equals("Rematik") || nilai.equals("rematik")) { + tumbuh[0].displaykandungan(); + System.out.println("\n\n"); + tumbuh[10].displaykandungan(); + System.out.println("\n\n"); + tumbuh[12].displaykandungan(); + System.out.println("\n\n"); + tumbuh[14].displaykandungan(); + System.out.println("\n\n"); + tumbuh[24].displaykandungan(); + } else if (nilai.equals("Wasir") || nilai.equals("wasir")) { + tumbuh[9].displaykandungan(); + System.out.println("\n\n"); + tumbuh[21].displaykandungan(); + System.out.println("\n\n"); + tumbuh[22].displaykandungan(); + } else if (nilai.equals("Anemia") || nilai.equals("anemia")) { + tumbuh[15].displaykandungan(); + System.out.println("\n\n"); + tumbuh[16].displaykandungan(); + } else if (nilai.equals("Kanker") || nilai.equals("kanker")) { + tumbuh[0].displaykandungan(); + System.out.println("\n\n"); + tumbuh[3].displaykandungan(); + System.out.println("\n\n"); + tumbuh[5].displaykandungan(); + System.out.println("\n\n"); + tumbuh[8].displaykandungan(); + System.out.println("\n\n"); + tumbuh[11].displaykandungan(); + System.out.println("\n\n"); + tumbuh[15].displaykandungan(); + } else if (nilai.equals("Jantung") || nilai.equals("jantung")) { + tumbuh[14].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + } else if (nilai.equals("Stroke") || nilai.equals("stroke")) { + tumbuh[13].displaykandungan(); + } else if (nilai.equals("Demam") || nilai.equals("demam")) { + tumbuh[4].displaykandungan(); + System.out.println("\n\n"); + tumbuh[7].displaykandungan(); + System.out.println("\n\n"); + tumbuh[8].displaykandungan(); + System.out.println("\n\n"); + tumbuh[12].displaykandungan(); + System.out.println("\n\n"); + tumbuh[13].displaykandungan(); + System.out.println("\n\n"); + tumbuh[16].displaykandungan(); + System.out.println("\n\n"); + tumbuh[20].displaykandungan(); + System.out.println("\n\n"); + tumbuh[24].displaykandungan(); + } else if (nilai.equals("Keputihan") || nilai.equals("keputihan")) { + tumbuh[10].displaykandungan(); + } else if (nilai.equals("TBC") || nilai.equals("tbc")) { + tumbuh[10].displaykandungan(); + } else if (nilai.equals("Sakit gigi") || nilai.equals("sakit gigi")) { + tumbuh[4].displaykandungan(); + } else if (nilai.equals("Maag") || nilai.equals("maag")) { + tumbuh[1].displaykandungan(); + } else if (nilai.equals("Kencing batu") || nilai.equals("kencing batu")) { + tumbuh[21].displaykandungan(); + } else if (nilai.equals("Asam urat") || nilai.equals("asam urat")) { + tumbuh[21].displaykandungan(); + } else if (nilai.equals("Radang gusi") || nilai.equals("radang gusi")) { + tumbuh[22].displaykandungan(); + } else if (nilai.equals("Cacingan") || nilai.equals("cacingan")) { + tumbuh[16].displaykandungan(); + tumbuh[23].displaykandungan(); + } else if (nilai.equals("Sakit perut") || nilai.equals("sakit perut")) { + tumbuh[8].displaykandungan(); + tumbuh[23].displaykandungan(); + } else if (nilai.equals("Cacar air") || nilai.equals("cacar air")) { + tumbuh[23].displaykandungan(); + } else if (nilai.equals("Bau mulut") || nilai.equals("bau mulut")) { + tumbuh[24].displaykandungan(); + } else if (nilai.equals("Batu ginjal") || nilai.equals("batu ginjal")) { + tumbuh[24].displaykandungan(); + } else { + System.out.println("TIDAK ADA DI DAFTAR PENCAHARIAN"); + } + } + if (data == 3) { + copy(); + tumbuhan1 []ab =SelectionSort(tumbuh); + tampilkan2(tumbuh2); + + System.out.print("Silahkan pilih daftar tumbuhan diatas:"); + pilih = readInt(); + tumbuh[pilih - 1].displaykandungan(); + + } + System.out.println("apakah anda ingin kembali lagi?y/n"); + ulang = readString(); + + } while (ulang.equals("y") || ulang.equals("Y")); + System.out.println("apakah anda mau kembali ke home?y/n"); + ulang2 = readString(); + } while (ulang2.equals("y") || ulang2.equals("Y")); + System.out.println(">>>>>>>>>>>>>>>TERIMA KASIH<<<<<<<<<<<<<<<"); + System.out.println("Semoga sehat selalu"); + System.out.println("Copyright Galuh Muhammad Iman Akbar"); + } catch (Exception e) { + System.out.println("Masukan inputan dengan benar"); + System.out.println(""); + daftar(); + } + + } +} + +public class ProjectUASv3Insertion { + + public static void main(String[] args) { + datatumbuhan1 panggil = new datatumbuhan1(25); + panggil.insert(1, "JAHE", "\n1.Minyak atsiri zingiberena (zingirona)\n2.zingiberol\n3.kurkumen\n4.gingerol\n5.filandrena\n6.resin pahit\n7.bisabolena", "MANFAAT:\n1.Menghangatkan badan\n2.menuruntkan berat badan\n3.menjaga kondisi jantung\n4.mengatasi mabuk perjalanan\n5.mengatasi gangguan pencernaan\n6.mencegah kanker usus\n7.mengobati sakit kepala\n8.mengomati alergi\n9.mengobati penyakit rematik\n10.meningkatkan sistem kekebalan tubuh", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT WEDANG JAHE:\n1.Jahe\n2.Gula pasir atau gula merah(Sesuai selera)\n3.Air", "CARA MEMBUAT WEDANG JAHE:\n1.kupas dan cuci jahe hingga bersih\n2.Rebus air hingga mendidih\n3.Sembari menunggu air mendidih, jahe dibakar sampai kemerah-merahan\n4.Kupas bagian yang terbakar\n5.Potong kecil-kecil dan dipukul agar aromanya keluar\n6.Masukan jahe yang telah di pukul ke dalam gelas\n7. Masukan gula secukupnya kedalam gelas\n8.Tuangkan air yang sudah dimasak tadi aduk hingga rata\n9.Hidangkan saat masih panas"); + panggil.insert(2, "KUNYIT", "\n1.kurkumin\n2.desmetoksikumin\n3.bisdesmetoksikurkumin\n4.Keton sesquiterpen\n5.turmeron\n6.Zingiberen", "MANFAAT:\n1.Sebagai ramuan anti peradangan tubuh\n2.Mengobati penyakit asam lambung\n3.Mengurangi gas pada pencernaan\n4.Meredakan sakit akibat irritable bowel syndrom\n5.Mengurangi mual\n6.Meredakan diare", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT JAMU KUNYIT:\n1.Empat gelas air\n2.Satu sendok teh kunyit parutan kunyit\n3.Lemon atau madu untuk ditambahkan pada tahap akhir", "CARA MEMBUAT JAMU KUNYIT:\n1.Rebus 4 gelas air sampai mendidih\n2.Masukkan 1 sendok teh kunyit ke air yang sedang mendidih\n3.Kecilkan api dan biarkan air yang sudah dicampur kunyit tersebut mendidih selama sekitar 10 menit\n4.Matikan api dan saring air kunyit tersebut menggunakan saringan yang halus\n5.Tuangkan hasil saringan tersebut ke dalam gelas dan tambahkan lemon atau madu sesuai selera"); + panggil.insert(3, "DAUN JAMBU BIJI", "\n1.Saponin\n2.Flavanoid\n3.Polifenol\n4.Alkaloid\n5.Karoten\n6.Steroid\n7.Kuinon\n8.Anti-oksidan\n9.Minyak atsiri\n10.Tannin\n11.Senyawa anti-mutagenic", "MANFAAT:\n1.Mengobati diare dan disentri\n2.Diabetes Mellitus\n3.Mengobati Luka Memar\n4.Mengatasi Jerawat\n5.Mengatasi Komedo\n6.Ambeien\n7.Mengusir kembung", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN JAMBU BIJI:\n1.Siapkan 7-10 lembar daun jambu biji\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN JAMBU BIJI:\n1.Cuci bersih daun tersebut dalam air yang mengalir\n2.Rebus 2-3 gelas air minum, setelah mendidih masukan daun jambu biji terlebus\n3.Rebus hingga air tersisa setengahnya sambil sesekali di aduk\n4.Setelah dingin ramuan air rebusan siap untuk di minum"); + panggil.insert(4, "TEMULAWAK", "\n1.Magnesium\n2.Phosphorus\n3.Zinc\n4.Asam folat\n5.Vitamin A\n6.Vitamin D", "MANFAAT:\n1.Memelihara Fungsi Hati\n2.Mengurangi radang sendi\n3.Masalah pencernaan\n4.Membantu Menurunkan Lemak Darah\n5.Melawan Kanker", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT JAMU TEMULAWAK:\n1.satu jari, rimpang temulawak iris-iris\n2.Sepuluh lembar, daun ungu\n3.Sstu gelas air putih 200ml", "CARA MEMBUAT JAMU TEMULAWAK:\n1.Bersihkan rimpang temulawak dengan daun ungu hingga bersih\n2.Setelah itu, rebus kedua bahan tersebut hingga mendidih\n3.Kemudian, angkat dan dinginkan lalu sharing\n4.Minum ramuan tersebut secara rutin 2 kali sehari sebanyak setengah gelas"); + panggil.insert(5, "SAMBILOTO", "\n1.Andrographolide\n2.Saponin\n3.Falvonoid\n4.Alkanoid\n5.Tanin\n6.Laktone\n7.Panikulin\n8.Kalmegin\n9.Hablur kuning", "MANFAAT:\n1.Dapat mengobati hepatitis\n2.Mengobati disentri basiler\n3.Mengobati sakit gigi\n4.Mengobati demam\n5.Mengobati Malaria", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN SAMBILOTO:\n1.Daun sambiloto\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN SAMBILOTO:\n1.Daun sambiloto segar sebanyak satu genggam\n2.Ditumbuk rata kemudian ditambahkan air matang sebanyak 110mL\n3.Saring kemudian minum sekaligus"); + panggil.insert(6, "KIJIBELING", ":\n1.Tripenoid\n2.Fosfor\n3.Natrium\n4.Kafein\n5.Kalsium\n6.Asam silikat\n7.Potassium", "MANFAAT:\n1.Menjaga kesehatan ginjal\n2.Diuretic alami\n3.Meningkatkan volume darah\n4.Mempercepat proses pembekuan darah\n5.Menghambat pertumbuhan kanker\n6.Mengatasi diare serta disentri\n7.Menjaga kesehatan organ hati\n8.Menurunkan kolestrol", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN KIJIBELING:\n1.Siapkan daun kijibeling sekitar 5-6 lembar\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN KIJIBELING:\n1.Rebus air bersamaan dengan daun kijibeling\n2.Tunggu hingga air setengah\n3.Setelah itu, angkat dan dinginkan\n4.Setelah dingin, minum ramuan tersebut dua kali sehari"); + panggil.insert(7, "KUMIS KUCING", ":\n1.Garam kalium\n2.Glikosida Orthosiphonim\n3.Mioinositol\n4.Minyak Atsiri\n5.Saponin\n6.Sapofonim\n7.Sinensetis\n8.Zat samak", "MANFAAT:\n1.Melancarkan air seni\n2.Mengobati batuk\n3.Mengobati sembelit\n4.Mengobati diabetes\n5.Mengobati gatal karena alergi", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN TUMBUHAN KUMIS KUCING:\n1.Siapkan 90 gr daun kumis kucing segar\n2.Satu gelas air putih", "CARA MEMBUAT AIR SEDUHAN DAUN TUMBUHAN KUMIS KUCING:\n1.Cuci daun kumis kucing sampai bersih\n2.Rebus daun kumis kucing tersebut dengan air hingga airnya tersisa 1/2 gelas saja\n3.Minum ramuan tersebut sebanyak 3x sehari dengan dosis 1/2 gelas"); + panggil.insert(8, "PEGAGAN", ":\n1.brahmoside\n2.brahmic acid\n3.brahminosid\n4.asiaticoside\n5.madecassoside\n6.madasiatic acid\n7.centelloside", "MANFAAT:\n1.Mengobati sariawan dan panas dalam\n2.Menghilangkan jerawat dan menghaluskan wajah\n3.Sebagai pembersih alami\n4.Melancarkan sirkulasi darah\n5.Menurunkan demam\n6.Meningkatkan tenaga dan stamina tubuh\n7.Meningkatkan sistem saraf ingatan", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN PEGAGAN\n1.Satu genggam daun pegagan\n2.Lima batang tapak lima\n3.Setengah genggam, daun jintan hitam\n4. Satu sendok madu\n5. Satu gelas air putih 200mL ", "CARA MEMBUAT SEDUHAN DAUN PEGAGAN:\n1.Cuci bersih semua bahan, lalu masukan dalam panci bersama satu gelas air\n2.Setelah itu rebus hingga mendidih\n3.Selanjutnya saring ainya dan beri campuran madu, aduk sampai rata\n4.Angkat dan minum air ramuan tersebut secara rutin sehari 2 kali pagi dan sore"); + panggil.insert(9, "CINCAU", ":\n1.Serat Makanan\n2.Fosfor\n3.Vitamin A\n4.Vitamin B1\n5.Vitamin C\n6.Protein\n7.Lemak\n8.Karbohidrat\n9.Energi", "MANFAAT:\n1.Mengobati sakit perut dan tekanan darah tinggi\n2.Mengobati demam\n3.Mengobati penyakit kanker", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT CINCAU:\n1.Air matang 300 mL\n2.Daun cincau 40 lembar yang sedang, cuci bersih", "CARA MEMBUAT CINCAU:\n1.Petama-tama remas-remas daun cincau segar\n2.Tuanglah 1/2 bagian air sedikit demi sedikit sambil terus diremas-remas sampai keluar lendir/gel berwarna hijau\n3.Selanjutnya saring remasan daun cincau\n4.Kemudian remas-remas kembali ampas (daun cincau) sambil tuang sisa air sampai keluar lendirnya. Setelah itu saring\n5.Nah sekarang simpan hasil saringan daun cincau dalam lemari pendingin sampai beku selama kurang lebih 3-4 jam\n6.Cincau hijau siap digunakan, bisa diolah lanjutan menjadi es cincau segar"); + panggil.insert(10, "LIDAH BUAYA", "\n1.Energi\n2.Protein\n3.Karbohidrat\n4.Kalsium\n5.Zat besi\n6.Vitamin A\n7.Vitamin B\n8.Vitamin C\n8.Fosfor", "MANFAAT:\n1.Penyubur rambut\n2.Sebagai anti oksidan\n3.Menghilangkan ketombe\n4.Detoksifikasi\n5.Menjaga kesehatan mulut\n6.Menjaga berat badan\n7.Mengobati wasir\n8.Menghilangkan jerawat", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT NATA DE ALOE VERA:\n1.Daun lidah buaya\n2.Garam\n3.Air", "CARA MEMBUAT NATA DE ALOE VERA:\n1.Daun lidah buaya dipotong sekitar per 10 cm menjadi 5 potong\n2.Hilangkan kulit yang berwarna hijau, tinggalkan dagaing ynag berwarna bening\n3.Dari potongan memanjang potong lagi menjadi kotak-kotak seperti nata de coco\n4.Kemudian cuci berulang-ulang sampai lendirnya habis\n5.Tambahkan garam dalam pencucian mungkin 2 sampai 3 kali saat membilasnya\n6.Kemudian rebuslah, tunggu 15 menit selama mendidih, setelah itu angkat, untuk mengurangi bau dapat ditambahkan daun pandan"); + panggil.insert(11, "BLUNTAS", "\n1.Alkanoid\n2.Pluchine\n3.Asam kafeoilkuniat\n4.Saponin\n5.polifenol\n6.Tannin\n7.Asam amino\n8.Kalsium\n9.Fosfor\n10.Vitamin A\n11.Vitamin C", "MANFAAT:\n1.Mengobati pencernaan pada anak-anak\n2.Mengatasi TBC kelenjar leher\n3.Mengatasi nyeri rematik\n4.Menghilangkan bau badan dan bau mulut\n5.Obat keputihan\n6.Mengatasi masalah hipertensi\n7.Melancarkan haid", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN BELUNTAS:\n1.Siapkan beberapa helai daun beluntas 3-5 lembar\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN BELUNTAS:\n1.Cuci daun beluntas sampai benar-benar bersih, kemudian rebus dengan 2 gelas air bersih\n2.Tunggu sampai mendidih hingga tersisa 1 gelas\n3.Angkat dan kemudian diamkan sampai menjadi hangat, minumlah secara rutin pagi dan sore hari"); + panggil.insert(12, "BELIMBING WULUH", "\n1.Glukosid\n2.Tanin\n3.Asam folat\n4.Peroksida\n5.Kalsium oksalat\n6.Sulfur\n7.Kalium sitrat", "MANFAAT:\n1.Obat sariawan dan mengatasi gusi berdarah\n2.Melancarkan pencernaan\n3.Menghaluskan kulit wajah\n4.Menyembuhkan batuk\n5.Menyembuhkan gondongan\n6.Mencegah penyakit kanker\n7.Mengatasi hipertensi\n8.Mengatasi rematik", "BAHAN-BAHAN YANG DIPERLUKAN BUAT SIRUP BELIMBING WULUH:\n1.200 gram belimbing wuluh yang segar dan sudah dicuci\n2. Satu setengah air putih\n3.Madu secukupnya\n4.Es batu secukupnya", "CARA MEMBUAT SIRUP BELIMBING WULUH:\n1.Potong kecil-kecil buah belimbing wuluh\n2.Masukan semua bahan ke dalam bender, lalu bender hingga halus\n3.Tuang jus kedalam gelas saji\n4.Jus belimbing siap untuk disajikan"); + panggil.insert(13, "BROTOWALI", "\n1.Glikosida pikroretosid\n2.Harsa\n3.Berberin\n4.Palmatin\n5.Alkaloid berberin", "MANFAAT:\n1.Mengobati rematik\n2.Mengobati demam kuning\n3.Mengobati diabetes\n4.Mengobati kudis\n5.Mengobati luka", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN AIR BROTOWALI:\n1.6cm batang brotowali\n2.Sepertiga genggam daun kumis kucing\n3.Sepertiga daun sambiloto\n4.Tiga gelas air", "CARA MEMBUAT SEDUAN AIR BROTOWALI:\n1.Cuci bersih dan potong-potong semua herba\n2.Rebuslah semua herba dengan 3 gelas air hingga mendidih dan tersisa 2 gelas air\n3.Setelah dingin, saring dan minum 1 gelas setelah makan 2 kali sehari"); + panggil.insert(14, "DAUN JINTEN", "\n1.Minyak atsiri\n2.Fenol\n3.Kalium", "MANFAAT:\n1.Mengembalikan kekebalan tubuh\n2.Obat demam\n3.Mengobati asma\n4.Sebagai obat batuk\n5.Mengobati penyakit stroke\n6.Mengobati rematik\n7.Mengobati perut kembung", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN JINTEN:\n1.Siapkan 6 lembar daun jinten\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN JINTEN:\n1.Cuci bersih daun jinten kemudian tumbuklah sampai halus\n2.Rebuslah air hingga mendidih\n3.Setelah air mendidih angkat kemudian tuangkan air ke dalam gelas yang sudah berisi daun jinten\n4.Air seduhan daun jinten siap dihidangkan"); + panggil.insert(15, "KAYU MANIS", "\n1.Eugenol\n2.Minyak atsiri\n3.tanin\n4.Sinamaldehide\n5.Kalsium oksalat\n6.Safrole\n7.Zat penyamak dan damar", "MANFAAT:\n1.Mengurangi rasa nyeri haid\n2.Mencegah terjadinya penggumpalan darah\n3.Mengurangi sakit rematik\n4.Mencegah penyakit jantung\n5.Menghangatkan tubuh\n6.Mengontrol gula darah", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT:\n1.Siapkan 1 batang kayu manis\n2.Madu\n3.Air secukupnya", "CARA MEMBUAT AIR SEDUHAN KAYU MANIS:\n1.Rebuslah air selama kurang lebih 5 menit\n2.Kemudian masukan kayu manis ke dalam air yang direbus\n3.Setelah itu tuangkan ke dalam gelas\n4.Tambahkan madu supaya lebih nikmat\n5.Air seduhan kayu manis siap dihidangkan"); + panggil.insert(16, "SELEDRI", "\n1.Kalium\n2.Folat\n3.Kalsium\n4.Vitamin K\n5.Serat", "MANFAAT:\n1.Mengobati rematik\n2.Mengobati anemia\n3.Mengobati batuk\n4.Memerangi kanker\n5.Menurunkan tekanan darah tinggi\n6.Mencegah asma\n7.Mencegah sembelit", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN SELEDRI:\n1.Daun seledri\n2.Air 3 gelas", "CARA MEMBUAT AIR SEDUHAN SELEDRI:\n1.Saipkan daun seledri\n2.Cuci hingga bersih\n3.Kemudian potong-potong\n4.Tuangkan 3 gelas kedalam panci\n5.Masukan daun seledri\n6.Tunggu airnya hingga menjadi 1 gelas:\n7.Air seduhan seledri siap diminum"); + panggil.insert(17, "DAUN KELOR", "\n1.Protein\n2.Fosfor\n3.Zat besi\n4.Kalsium\n5.Vitamin B1\n6.Vitamin C\n7.Vitamin A", "MANFAAT:\n1.Antimikroba\n2.Mencegah rematik\n3.Mengobati demam\n4.Mengobati anemia\n5.Mengobati diabetes\n6.Mengobati cacingan", "BAHAN-BAHAN YANG DIPERLUKAN UTNUK MEMBUAT TEH DAUN KELOR:\n1.Daun kelor yang sudah di keringkan\n2.Air secukupnya\n3.Madu", "CARA MEMBUAT TEH DAUN KELOR:\n1.Siapkan daun kelor yang sudah di keringkan\n2.Rebus air hingga mendidih\n3.Kemudian masukan air ke dalam gelas yang sudah berisi daun kelor\n4.Setelah itu saring daun kelor tersebut\n5.Air teh daun kelor siap dihidangkan"); + panggil.insert(18, "DAUN MURBEI", "\n1.Eugenol\n2.Betahexenal\n3.Benzaidehide\n4.Vitamin A\n5.Vitamin B1\n6.Vitamin C\n7.Karoten", "MANFAAT:\n1.Mengobati tekanan darah tinggi\n2.Mengobati rematik\n3.Mengobati hepatitis kronis\n4.Menggobati gigitan ular\n5.Mengobati jantung lemah", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT TEH MURBEI:\n1.Pucuk daun teh murbei yang sudah kering\n2.Air secukup nya", "CARA MEMBUAT TEH MURBEI:\n1.Siapkan pucuk daun teh murbei yang sudah di keringkan\n2.Rebus air hingga mendidih\n3.Tuangkan air kedalam gelas yang sudah berisi daun murbei\n4.Kemudian saring, dan teh daun murbei sudah siap diminum"); + panggil.insert(19, "SIRIH MERAH", "\n1.Allyprokatekol\n2.Alkaloid\n3.Cineole\n4.Extragol\n5.Eugenol\n6.F enil propoda\n7.Minyak atsiri", "MANFAAT:\n1.Mengobati Mata merah\n2.Mengobati gusi berdarah\n3.Mengobati penyakit bronkitis\n4.Mengobati darah tinggi\n5.Mengobati batuk\n6.Mengobati tumor\n7.Mengobati diabetes", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN DAUN SIRIH MERAH:\n1.Sirih merah secukupnya\n2.Air secukupnya", "CARA MEMBUAT SEDUHAN DAUN SIRIH MERAH:\n1.Siapkan sirih merah\n2.Rebus Air hingga mendidih\n3.Kemudain masukan sirih merah ke dalam air mendidih\n4.Saring air seduhan sirih merah dan tuangkan ke dalam gelas\n5.Air seduhan sirih merah siap diminum"); + panggil.insert(20, "DAUN ASAM", "\n1.Flavanoid\n2.Asam askorbat\n3.Tanin\n4.Vitamin C", "MANFAAT:\n1.Sebagai obat asma\n2.Sebagai obat batuk kering\n3.Mengobati malaria\n4.Menyembuhkan peradangan\n5.Mencegah penyakit kuning", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN DAUN ASAM:\n1.Segenggam daun asam\n2.Lima ruas kunyit\n3.Air secukupnya", "CARA MEMBUAT SEDUHAN DAUN ASAM:\n1.Tumbuk 1 genggam daun asam dan 5 ruas kunyit\n2.Rebus dengan air 300 cc hinggan menjadi 200 cc\n3.Kemudian tuangkan kedalam gelas\n4.Supaya lebih nikmat tambahkan gula aren secukupnya\n5.Diamkan hingga dingin lalu minum"); + panggil.insert(21, "ALANG-ALANG", "\n1.Silindrin\n2.Isoarbolinol\n3.Simiarenol\n4.Fernenol\n5.Arun doin\n6.Asam klorogenat\n7.Katekol\n8.Asam Isoklorogenat\n9.Asam oksalat\n1 0.Asam asetat\n11.Asam sitrat", "MANFAAT:\n1.Sebagai obat asma\n2.Mengobati hepatitis\n3.Mengobati diare\n4.Penyakit jantung\n5.Infeksi ginjal\n6.Demam\n7.Hipertensi", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN ALANG-ALANG:\n1.Air mineral 2 gelas\n2.Alang-alang secukupnya", "CARA MEMBUAT SEDUHAN ALANG-ALANG:\n1.Siapkan alang-alang secukupnya\n2.Cuci terlebih dulu alang-alang hingga bersih\n3.Potong kecil alang-alang\n4.Rebus hingga mendidih\n5.Terakhir angkat, diinginkan dan saring ampasnya\n6.Air rebusan alang-alang siap diminum"); + panggil.insert(22, "DAUN TEMPUYUNG", "\n1.Flavanoid\n2.Taraksasterol\n3.Inositol\n4.Kumarin\n5.Asam fenolat", "MANFAAT:\n1.Mengobati kencing batu\n2.Mengobati asam urat\n3.Mengobati wasir\n4.Mengobati wasir", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN DAUN TEMPUYUNG:\n1.Air mineral\n2.Daun tempuyung secukupnya", "CARA MEMBUAT SEDUHAN DAUN TEMPUYUNG:\n1.Siapkan daun tempuyung yang masih segar\n2.Cuci terlebih dahulu hingga bersih\n3.Seduh hingga medidih\n4.Saring dan kemudian dinginkan\n5.Air daun tempuyung siap diminum"); + panggil.insert(23, "DAUN ANDONG", "\n1.Saponin\n2.Tanin\n3.Flavonoid\n4.Polifenol\n5.Steroida\n6.Kalsium oksalat\n7.Zat besi", "MANFAAT:\n1.Mengobati radang gusi\n2.Mengobati diare\n3.Mengobati wasir", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT DAUN TEMPUYUNG:\n1.Air mineral\n2.Daun andong secukupnya", "CARA MEMBUAT SEDUHAN DAUN ANDONG:\n1.Siapkan daun andong yang masih segar\n2.Cuci hingga bersih\n3.Masukan daun andong kemudian rebus hingga mendidih\n4.Saring daun andong dan dinginkan\n5.Air daun andong siap untuk diminum"); + panggil.insert(24, "TEMU GIRING", "\n1.Tannin\n2.Minyak atsiri\n3.Flavonoida\n4.Piperazin sitrat\n5.Damar\n6.Kurkumin\n7.Protein\n8.Lemak", "MANFAAT:\n1.Mengobati cacingan\n2.Obat sakit perut\n3.Mengobati cacar air\n4.Mengobati kudis", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT JAMU TEMU GIRING:\n1.Air mineral\n2.Temu giring\n3.Madu", "CARA MEMBUAT JAMU TEMU GIRING:\n1.Cuci temu giring hingga bersih\n2.Parut temu ginring hingga halus\n3.Masukan hasil arutan kedalam gelas\n4.Rebus air hingga mendidih\n5.Tuangkan air ke dalam gelas yang berisi hasil parutan temu giring\n6.Saring dan tambahkan madu supaya lebih nikmat\n7.Jamu temu giring siap diminum"); + panggil.insert(25, "AKAR WANGI", "\n1.Senyawa karbonil\n2.Ester\n3.Vetiveron\n4.Seskuiterpen\n5.Seskuiterpen derivatif", "MANFAAT:\n1.Mengatasi bau mulut\n2.Mengobati rematik\n3.Mengobati batu ginjal\n4.Menurunkan demam", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN AKAR WANGI:\n1.Akar wangi secukupnya\n2.Air secukupnya\n3.Garam", "CARA MEMBUAT SEDUHAN AKAR WANGI:\n1.Cuci terlebih dahulu akar wangi\n2.Potong-potong akar wangi, rebus dengan air sampai mendidih\n3.Masukan garam secukupnya\n4.Tunggu hingga air mengeluarkan wangi\n5.Tuangkan air di gelas tunggu hingga hangat\n6.Air akar wangi siap untuk diminum"); + panggil.daftar(); + + + } +} diff --git a/project_UAS2/src/projectUAS3/test5.java b/project_UAS2/src/projectUAS3/test5.java new file mode 100644 index 00000000..41c9b369 --- /dev/null +++ b/project_UAS2/src/projectUAS3/test5.java @@ -0,0 +1,36 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package projectUAS3; + +/** + * + * @author humane + */ +public class test5 { + + public static String inputString() { + int karakter; + String str = ""; + boolean selesai = false; + while (!selesai); + { + try { + karakter = System.in.read(); + if (karakter < 0 || (char) karakter == '\n') { + selesai = true; + } else if ((char) karakter != '\r') { + str = str + (char) karakter; + } + } catch (java.io.IOException e) { + System.out.println("Ada kesalahan"); + selesai = true; + } + + } + return str; + } + +} diff --git a/project_UAS2/src/project_uas2/ProjectUASv3.java b/project_UAS2/src/project_uas2/ProjectUASv3.java new file mode 100644 index 00000000..1c600288 --- /dev/null +++ b/project_UAS2/src/project_uas2/ProjectUASv3.java @@ -0,0 +1,93 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package project_uas2; + +/** + * + * @author USER + */ +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.*; +class tumbuhan { + + private int urutan; + private String nama_tumbuhan; + private String kandungan; + private String manfaat; + private String bahan_bahan; + private String cara_membuat; + + public tumbuhan(int urutan, String nama_tumbuhan, String kandungan, String manfaat, String bahan_bahan, String cara_membuat) { + this.urutan = urutan; + this.kandungan = kandungan; + this.manfaat = manfaat; + this.bahan_bahan = bahan_bahan; + this.cara_membuat = cara_membuat; + this.nama_tumbuhan = nama_tumbuhan; + } + + public void displaytumbuhan() { + System.out.println(urutan + ". " + nama_tumbuhan); + } + + public void displaykandungan() { + System.out.println("==" + nama_tumbuhan + "==\n" + "Kandungan " + nama_tumbuhan + "\n" + kandungan + "Manfaat\n" + manfaat + "Bahan-Bahan yang diperlukan\n" + bahan_bahan + "Cara membuatnya\n" + cara_membuat); + } + + public String getNamaTumbuhan() { + return nama_tumbuhan; + } + + public String getKandungan() { + return kandungan; + } + + public String getManfaat() { + return manfaat; + } + + public String getBahan_bahan() { + return bahan_bahan; + } + + public String getCaramembuat() { + return cara_membuat; + } + + class datatumbuhan { + private tumbuhan[]tumbuh; + private int nElemen; + + public datatumbuhan(int max){ + tumbuh=new tumbuhan[max]; + nElemen=0; + } + public void insert(int urutan, String nama_tumbuhan, String kandungan, String manfaat, String bahan_bahan, String cara_membuat){ + tumbuh[nElemen]=new tumbuhan(urutan, nama_tumbuhan, kandungan, manfaat, bahan_bahan, cara_membuat); + nElemen++; + } + public String readString(){ + BufferedReader a=new BufferedReader(new InputStreamReader(System.in)); + String String = ""; + try { + String =a.readLine(); + } catch (Exception e) { + System.out.println(e); + } + return String; + } + public int readInt(){ + return Integer.parseInt(readString()); + } + } +} + public class ProjectUASv3 { + public static void main(String[] args) { + datatumbuhan panggil=new datatumbuhan(25); + } + } + diff --git a/project_UAS2/src/project_uas2/Project_UAS2.java b/project_UAS2/src/project_uas2/Project_UAS2.java new file mode 100644 index 00000000..4d3a6685 --- /dev/null +++ b/project_UAS2/src/project_uas2/Project_UAS2.java @@ -0,0 +1,686 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package project_uas2; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.Scanner; + +/** + * + * @author USER + */ +public class Project_UAS2 { + + String data; + String cari = ""; + int jumlah = 0; + public static Scanner input = new Scanner(System.in); + //kode warna merah + public static String ANSI_RED = "\u001B[31m"; + //kode warna hijau + public static String ANSI_GREEN = "\u001B[32m"; + //kode warna ungu + public static String ANSI_PURPLE = "\u001B[35m"; + //kode warna kuning + public static String ANSI_YELLOW = "\u001B[33m"; + //kode warna biru + public static String ANSI_BLUE = "\u001B[34m"; + + //method jahe + public static void jahe() { + String jahe[] = {"\nKANDUNGAN JAHE\n1.Minyak atsiri zingiberena (zingirona)\n2.zingiberol\n3.kurkumen\n4.gingerol\n5.filandrena\n6.resin pahit\n7.bisabolena", "MANFAAT:\n1.Menghangatkan badan\n2.menuruntkan berat badan\n3.menjaga kondisi jantung\n4.mengatasi mabuk perjalanan\n5.mengatasi gangguan pencernaan\n6.mencegah kanker usus\n7.mengobati sakit kepala\n8.mengomati alergi\n9.mengobati penyakit rematik\n10.meningkatkan sistem kekebalan tubuh", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT WEDANG JAHE:\n1.Jahe\n2.Gula pasir atau gula merah(Sesuai selera)\n3.Air", "CARA MEMBUAT WEDANG JAHE:\n1.kupas dan cuci jahe hingga bersih\n2.Rebus air hingga mendidih\n3.Sembari menunggu air mendidih, jahe dibakar sampai kemerah-merahan\n4.Kupas bagian yang terbakar\n5.Potong kecil-kecil dan dipukul agar aromanya keluar\n6.Masukan jahe yang telah di pukul ke dalam gelas\n7. Masukan gula secukupnya kedalam gelas\n8.Tuangkan air yang sudah dimasak tadi aduk hingga rata\n9.Hidangkan saat masih panas"}; + for (int i = 0; i < jahe.length; i++) { + System.out.println(ANSI_RED + "==JAHE==" + jahe[i]); + + } + } + + //method kunyit + public static void kunyit() { + String kunyit[] = {"\nKANDUNGAN KUNYIT:\n1.kurkumin\n2.desmetoksikumin\n3.bisdesmetoksikurkumin\n4.Keton sesquiterpen\n5.turmeron\n6.Zingiberen", "MANFAAT:\n1.Sebagai ramuan anti peradangan tubuh\n2.Mengobati penyakit asam lambung\n3.Mengurangi gas pada pencernaan\n4.Meredakan sakit akibat irritable bowel syndrom\n5.Mengurangi mual\n6.Meredakan diare", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT JAMU KUNYIT:\n1.Empat gelas air\n2.Satu sendok teh kunyit parutan kunyit\n3.Lemon atau madu untuk ditambahkan pada tahap akhir", "CARA MEMBUAT JAMU KUNYIT:\n1.Rebus 4 gelas air sampai mendidih\n2.Masukkan 1 sendok teh kunyit ke air yang sedang mendidih\n3.Kecilkan api dan biarkan air yang sudah dicampur kunyit tersebut mendidih selama sekitar 10 menit\n4.Matikan api dan saring air kunyit tersebut menggunakan saringan yang halus\n5.Tuangkan hasil saringan tersebut ke dalam gelas dan tambahkan lemon atau madu sesuai selera"}; + for (int i = 0; i < kunyit.length; i++) { + System.out.println(ANSI_GREEN + "==KUNYIT==" + kunyit[i]); + } + } + + //method daun jambu biji + public static void daunjambubiji() { + String daunjambubiji[] = {"\nKANDUNGAN DAUN JAMBU BIJI:\n1.Saponin\n2.Flavanoid\n3.Polifenol\n4.Alkaloid\n5.Karoten\n6.Steroid\n7.Kuinon\n8.Anti-oksidan\n9.Minyak atsiri\n10.Tannin\n11.Senyawa anti-mutagenic", "MANFAAT:\n1.Mengobati diare dan disentri\n2.Diabetes Mellitus\n3.Mengobati Luka Memar\n4.Mengatasi Jerawat\n5.Mengatasi Komedo\n6.Ambeien\n7.Mengusir kembung", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN JAMBU BIJI:\n1.Siapkan 7-10 lembar daun jambu biji\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN JAMBU BIJI:\n1.Cuci bersih daun tersebut dalam air yang mengalir\n2.Rebus 2-3 gelas air minum, setelah mendidih masukan daun jambu biji terlebus\n3.Rebus hingga air tersisa setengahnya sambil sesekali di aduk\n4.Setelah dingin ramuan air rebusan siap untuk di minum"}; + for (int i = 0; i < daunjambubiji.length; i++) { + System.out.println(ANSI_PURPLE + "==DAUN JAMBU BIJI==" + daunjambubiji[i]); + } + } + + //method temulawak + public static void temulawak() { + String temulawak[] = {"\nKANDUNGAN TEMULAWAK:\n1.Magnesium\n2.Phosphorus\n3.Zinc\n4.Asam folat\n5.Vitamin A\n6.Vitamin D", "MANFAAT:\n1.Memelihara Fungsi Hati\n2.Mengurangi radang sendi\n3.Masalah pencernaan\n4.Membantu Menurunkan Lemak Darah\n5.Melawan Kanker", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT JAMU TEMULAWAK:\n1.satu jari, rimpang temulawak iris-iris\n2.Sepuluh lembar, daun ungu\n3.Sstu gelas air putih 200ml", "CARA MEMBUAT JAMU TEMULAWAK:\n1.Bersihkan rimpang temulawak dengan daun ungu hingga bersih\n2.Setelah itu, rebus kedua bahan tersebut hingga mendidih\n3.Kemudian, angkat dan dinginkan lalu sharing\n4.Minum ramuan tersebut secara rutin 2 kali sehari sebanyak setengah gelas"}; + for (int i = 0; i < temulawak.length; i++) { + System.out.println(ANSI_YELLOW + "==TEMULAWAK==" + temulawak[i]); + } + } + + //method sambiloto + public static void sambiloto() { + String sambiloto[] = {"\nKANDUNGAN SAMBILITO:\n1.Andrographolide\n2.Saponin\n3.Falvonoid\n4.Alkanoid\n5.Tanin\n6.Laktone\n7.Panikulin\n8.Kalmegin\n9.Hablur kuning", "MANFAAT:\n1.Dapat mengobati hepatitis\n2.Mengobati disentri basiler\n3.Mengobati sakit gigi\n4.Mengobati demam\n5.Mengobati Malaria", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN SAMBILOTO:\n1.Daun sambiloto\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN SAMBILOTO:\n1.Daun sambiloto segar sebanyak satu genggam\n2.Ditumbuk rata kemudian ditambahkan air matang sebanyak 110mL\n3.Saring kemudian minum sekaligus"}; + for (int i = 0; i < sambiloto.length; i++) { + System.out.println(ANSI_BLUE + "==SAMBILOTO==" + sambiloto[i]); + } + } + + //method kijibeling + public static void kijibeling() { + String kijibeling[] = {"\nKANDUNGAN KIJIBELING:\n1.Tripenoid\n2.Fosfor\n3.Natrium\n4.Kafein\n5.Kalsium\n6.Asam silikat\n7.Potassium", "MANFAAT:\n1.Menjaga kesehatan ginjal\n2.Diuretic alami\n3.Meningkatkan volume darah\n4.Mempercepat proses pembekuan darah\n5.Menghambat pertumbuhan kanker\n6.Mengatasi diare serta disentri\n7.Menjaga kesehatan organ hati\n8.Menurunkan kolestrol", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN KIJIBELING:\n1.Siapkan daun kijibeling sekitar 5-6 lembar\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN KIJIBELING:\n1.Rebus air bersamaan dengan daun kijibeling\n2.Tunggu hingga air setengah\n3.Setelah itu, angkat dan dinginkan\n4.Setelah dingin, minum ramuan tersebut dua kali sehari"}; + for (int i = 0; i < kijibeling.length; i++) { + System.out.println(ANSI_RED + "==KIJIBELING==" + kijibeling[i]); + } + } + + //method kumis kucing + public static void kumiskucing() { + String kumiskucing[] = {"\nKADUNGAN TUMBUHAN KUMIS KUCING:\n1.Garam kalium\n2.Glikosida Orthosiphonim\n3.Mioinositol\n4.Minyak Atsiri\n5.Saponin\n6.Sapofonim\n7.Sinensetis\n8.Zat samak", "MANFAAT:\n1.Melancarkan air seni\n2.Mengobati batuk\n3.Mengobati sembelit\n4.Mengobati diabetes\n5.Mengobati gatal karena alergi", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN TUMBUHAN KUMIS KUCING:\n1.Siapkan 90 gr daun kumis kucing segar\n2.Satu gelas air putih", "CARA MEMBUAT AIR SEDUHAN DAUN TUMBUHAN KUMIS KUCING:\n1.Cuci daun kumis kucing sampai bersih\n2.Rebus daun kumis kucing tersebut dengan air hingga airnya tersisa 1/2 gelas saja\n3.Minum ramuan tersebut sebanyak 3x sehari dengan dosis 1/2 gelas"}; + for (int i = 0; i < kumiskucing.length; i++) { + System.out.println(ANSI_GREEN + "==KUMIS KUCING==" + kumiskucing[i]); + } + } + + //method pegagan + public static void pegagan() { + String pegagan[] = {"\nKANDUNGAN PEGAGAN:\n1.brahmoside\n2.brahmic acid\n3.brahminosid\n4.asiaticoside\n5.madecassoside\n6.madasiatic acid\n7.centelloside", "MANFAAT:\n1.Mengobati sariawan dan panas dalam\n2.Menghilangkan jerawat dan menghaluskan wajah\n3.Sebagai pembersih alami\n4.Melancarkan sirkulasi darah\n5.Menurunkan demam\n6.Meningkatkan tenaga dan stamina tubuh\n7.Meningkatkan sistem saraf ingatan", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN PEGAGAN\n1.Satu genggam daun pegagan\n2.Lima batang tapak lima\n3.Setengah genggam, daun jintan hitam\n4. Satu sendok madu\n5. Satu gelas air putih 200mL", "CARA MEMBUAT SEDUHAN DAUN PEGAGAN:\n1.Cuci bersih semua bahan, lalu masukan dalam panci bersama satu gelas air\n2.Setelah itu rebus hingga mendidih\n3.Selanjutnya saring ainya dan beri campuran madu, aduk sampai rata\n4.Angkat dan minum air ramuan tersebut secara rutin sehari 2 kali pagi dan sore"}; + for (int i = 0; i < pegagan.length; i++) { + System.out.println(ANSI_PURPLE + "==PEGAGAN==" + pegagan[i]); + } + } + + //method daun cincau + public static void dauncincau() { + String dauncincau[] = {"\nKANDUNGAN DAUN CINCAU:\n1.Serat Makanan\n2.Fosfor\n3.Vitamin A\n4.Vitamin B1\n5.Vitamin C\n6.Protein\n7.Lemak\n8.Karbohidrat\n9.Energi", "MANFAAT:\n1.Mengobati sakit perut dan tekanan darah tinggi\n2.Mengobati demam\n3.Mengobati penyakit kanker", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT CINCAU:\n1.Air matang 300 mL\n2.Daun cincau 40 lembar yang sedang, cuci bersih", "CARA MEMBUAT CINCAU:\n1.Petama-tama remas-remas daun cincau segar\n2.Tuanglah 1/2 bagian air sedikit demi sedikit sambil terus diremas-remas sampai keluar lendir/gel berwarna hijau\n3.Selanjutnya saring remasan daun cincau\n4.Kemudian remas-remas kembali ampas (daun cincau) sambil tuang sisa air sampai keluar lendirnya. Setelah itu saring\n5.Nah sekarang simpan hasil saringan daun cincau dalam lemari pendingin sampai beku selama kurang lebih 3-4 jam\n6.Cincau hijau siap digunakan, bisa diolah lanjutan menjadi es cincau segar"}; + for (int i = 0; i < dauncincau.length; i++) { + System.out.println(ANSI_YELLOW + "==DAUN CINCAU==" + dauncincau[i]); + } + } + + //method lidah buaya + public static void lidahbuaya() { + String lidahbuaya[] = {"\nKANDUNGAN LIDAH BUAYA:\n1.Energi\n2.Protein\n3.Karbohidrat\n4.Kalsium\n5.Zat besi\n6.Vitamin A\n7.Vitamin B\n8.Vitamin C\n8.Fosfor", "MANFAAT:\n1.Penyubur rambut\n2.Sebagai anti oksidan\n3.Menghilangkan ketombe\n4.Detoksifikasi\n5.Menjaga kesehatan mulut\n6.Menjaga berat badan\n7.Mengobati wasir\n8.Menghilangkan jerawat", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT NATA DE ALOE VERA:\n1.Daun lidah buaya\n2.Garam\n3.Air", "CARA MEMBUAT NATA DE ALOE VERA:\n1.Daun lidah buaya dipotong sekitar per 10 cm menjadi 5 potong\n2.Hilangkan kulit yang berwarna hijau, tinggalkan dagaing ynag berwarna bening\n3.Dari potongan memanjang potong lagi menjadi kotak-kotak seperti nata de coco\n4.Kemudian cuci berulang-ulang sampai lendirnya habis\n5.Tambahkan garam dalam pencucian mungkin 2 sampai 3 kali saat membilasnya\n6.Kemudian rebuslah, tunggu 15 menit selama mendidih, setelah itu angkat, untuk mengurangi bau dapat ditambahkan daun pandan"}; + for (int i = 0; i < lidahbuaya.length; i++) { + System.out.println(ANSI_BLUE + "==LIDAH BUAYA==" + lidahbuaya[i]); + } + } + + //method daun beluntas + public static void daunbeluntas() { + String daunbeluntas[] = {"\nKANDUNGAN DAUN BELUNTAS:\n1.Alkanoid\n2.Pluchine\n3.Asam kafeoilkuniat\n4.Saponin\n5.polifenol\n6.Tannin\n7.Asam amino\n8.Kalsium\n9.Fosfor\n10.Vitamin A\n11.Vitamin C", "MANFAAT:\n1.Mengobati pencernaan pada anak-anak\n2.Mengatasi TBC kelenjar leher\n3.Mengatasi nyeri rematik\n4.Menghilangkan bau badan dan bau mulut\n5.Obat keputihan\n6.Mengatasi masalah hipertensi\n7.Melancarkan haid", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN BELUNTAS:\n1.Siapkan beberapa helai daun beluntas 3-5 lembar\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN BELUNTAS:\n1.Cuci daun beluntas sampai benar-benar bersih, kemudian rebus dengan 2 gelas air bersih\n2.Tunggu sampai mendidih hingga tersisa 1 gelas\n3.Angkat dan kemudian diamkan sampai menjadi hangat, minumlah secara rutin pagi dan sore hari"}; + for (int i = 0; i < daunbeluntas.length; i++) { + System.out.println(ANSI_PURPLE + "==DAUN BELUNTAS==" + daunbeluntas[i]); + } + } + + //method belimbing wuluh + public static void belimbingwuluh() { + String belimbingwuluh[] = {"\nKANDUNGAN BELIMBING WULUH:\n1.Glukosid\n2.Tanin\n3.Asam folat\n4.Peroksida\n5.Kalsium oksalat\n6.Sulfur\n7.Kalium sitrat", "MANFAAT:\n1.Obat sariawan dan mengatasi gusi berdarah\n2.Melancarkan pencernaan\n3.Menghaluskan kulit wajah\n4.Menyembuhkan batuk\n5.Menyembuhkan gondongan\n6.Mencegah penyakit kanker\n7.Mengatasi hipertensi\n8.Mengatasi rematik", "BAHAN-BAHAN YANG DIPERLUKAN BUAT SIRUP BELIMBING WULUH:\n1.200 gram belimbing wuluh yang segar dan sudah dicuci\n2. Satu setengah air putih\n3.Madu secukupnya\n4.Es batu secukupnya", "CARA MEMBUAT SIRUP BELIMBING WULUH:\n1.Potong kecil-kecil buah belimbing wuluh\n2.Masukan semua bahan ke dalam bender, lalu bender hingga halus\n3.Tuang jus kedalam gelas saji\n4.Jus belimbing siap untuk disajikan"}; + for (int i = 0; i < belimbingwuluh.length; i++) { + System.out.println(ANSI_RED + "==BELIMBING WULUH==" + belimbingwuluh[i]); + } + } + + //method brotowali + public static void brotowali() { + String brotowali[] = {"\nKANDUNGAN BROTOWALI:\n1.Glikosida pikroretosid\n2.Harsa\n3.Berberin\n4.Palmatin\n5.Alkaloid berberin", "MANFAAT:\n1.Mengobati rematik\n2.Mengobati demam kuning\n3.Mengobati diabetes\n4.Mengobati kudis\n5.Mengobati luka", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN AIR BROTOWALI:\n1.6cm batang brotowali\n2.Sepertiga genggam daun kumis kucing\n3.Sepertiga daun sambiloto\n4.Tiga gelas air", "CARA MEMBUAT SEDUAN AIR BROTOWALI:\n1.Cuci bersih dan potong-potong semua herba\n2.Rebuslah semua herba dengan 3 gelas air hingga mendidih dan tersisa 2 gelas air\n3.Setelah dingin, saring dan minum 1 gelas setelah makan 2 kali sehari"}; + for (int i = 0; i < brotowali.length; i++) { + System.out.println(ANSI_YELLOW + "==BROTOWALI==" + brotowali[i]); + } + } + + //method daun jinten + public static void daunjinten() { + String daunjinten[] = {"\nKANDUNGAN DAUN JINTEN:\n1.Minyak atsiri\n2.Fenol\n3.Kalium", "MANFAAT:\n1.Mengembalikan kekebalan tubuh\n2.Obat demam\n3.Mengobati asma\n4.Sebagai obat batuk\n5.Mengobati penyakit stroke\n6.Mengobati rematik\n7.Mengobati perut kembung", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN JINTEN:\n1.Siapkan 6 lembar daun jinten\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN JINTEN:\n1.Cuci bersih daun jinten kemudian tumbuklah sampai halus\n2.Rebuslah air hingga mendidih\n3.Setelah air mendidih angkat kemudian tuangkan air ke dalam gelas yang sudah berisi daun jinten\n4.Air seduhan daun jinten siap dihidangkan"}; + for (int i = 0; i < daunjinten.length; i++) { + System.out.println(ANSI_BLUE + "==DAUN JINTEN==" + daunjinten[i]); + } + } + + //method kayu manis + public static void kayumanis() { + String kayumanis[] = {"\nKANDUNGAN KAYU MANIS:\n1.Eugenol\n2.Minyak atsiri\n3.tanin\n4.Sinamaldehide\n5.Kalsium oksalat\n6.Safrole\n7.Zat penyamak dan damar", "MANFAAT:\n1.Mengurangi rasa nyeri haid\n2.Mencegah terjadinya penggumpalan darah\n3.Mengurangi sakit rematik\n4.Mencegah penyakit jantung\n5.Menghangatkan tubuh\n6.Mengontrol gula darah", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT:\n1.Siapkan 1 batang kayu manis\n2.Madu\n3.Air secukupnya", "CARA MEMBUAT AIR SEDUHAN KAYU MANIS:\n1.Rebuslah air selama kurang lebih 5 menit\n2.Kemudian masukan kayu manis ke dalam air yang direbus\n3.Setelah itu tuangkan ke dalam gelas\n4.Tambahkan madu supaya lebih nikmat\n5.Air seduhan kayu manis siap dihidangkan"}; + for (int i = 0; i < kayumanis.length; i++) { + System.out.println(ANSI_GREEN + "==KAYU MANIS==" + kayumanis[i]); + } + } + + //method seledri + public static void seledri() { + String seledri[] = {"\nKANDUNGAN SELEDRI:\n1.Kalium\n2.Folat\n3.Kalsium\n4.Vitamin K\n5.Serat", "MANFAAT:\n1.Mengobati rematik\n2.Mengobati anemia\n3.Mengobati batuk\n4.Memerangi kanker\n5.Menurunkan tekanan darah tinggi\n6.Mencegah asma\n7.Mencegah sembelit", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN SELEDRI:\n1.Daun seledri\n2.Air 3 gelas", "CARA MEMBUAT AIR SEDUHAN SELEDRI:\n1.Saipkan daun seledri\n2.Cuci hingga bersih\n3.Kemudian potong-potong\n4.Tuangkan 3 gelas kedalam panci\n5.Masukan daun seledri\n6.Tunggu airnya hingga menjadi 1 gelas:\n7.Air seduhan seledri siap diminum"}; + for (int i = 0; i < seledri.length; i++) { + System.out.println(ANSI_RED + "==SELEDRI==" + seledri[i]); + } + } + + //method daun kelor + public static void daunkelor() { + String daunkelor[] = {"\nKANDUNGAN DAUN KELOR:\n1.Protein\n2.Fosfor\n3.Zat besi\n4.Kalsium\n5.Vitamin B1\n6.Vitamin C\n7.Vitamin A", "MANFAAT:\n1.Antimikroba\n2.Mencegah rematik\n3.Mengobati demam\n4.Mengobati anemia\n5.Mengobati diabetes\n6.Mengobati cacingan", "BAHAN-BAHAN YANG DIPERLUKAN UTNUK MEMBUAT TEH DAUN KELOR:\n1.Daun kelor yang sudah di keringkan\n2.Air secukupnya\n3.Madu", "CARA MEMBUAT TEH DAUN KELOR:\n1.Siapkan daun kelor yang sudah di keringkan\n2.Rebus air hingga mendidih\n3.Kemudian masukan air ke dalam gelas yang sudah berisi daun kelor\n4.Setelah itu saring daun kelor tersebut\n5.Air teh daun kelor siap dihidangkan"}; + for (int i = 0; i < daunkelor.length; i++) { + System.out.println(ANSI_PURPLE + "==DAUN KELOR==" + daunkelor[i]); + } + } + + //method daun murbei + public static void daunmurbei() { + String daunmurbei[] = {"\nKANDUNGAN DAUN MURBEI:\n1.Eugenol\n2.Betahexenal\n3.Benzaidehide\n4.Vitamin A\n5.Vitamin B1\n6.Vitamin C\n7.Karoten", "MANFAAT:\n1.Mengobati tekanan darah tinggi\n2.Mengobati rematik\n3.Mengobati hepatitis kronis\n4.Menggobati gigitan ular\n5.Mengobati jantung lemah", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT TEH MURBEI:\n1.Pucuk daun teh murbei yang sudah kering\n2.Air secukup nya", "CARA MEMBUAT TEH MURBEI:\n1.Siapkan pucuk daun teh murbei yang sudah di keringkan\n2.Rebus air hingga mendidih\n3.Tuangkan air kedalam gelas yang sudah berisi daun murbei\n4.Kemudian saring, dan teh daun murbei sudah siap diminum"}; + for (int i = 0; i < daunmurbei.length; i++) { + System.out.println(ANSI_YELLOW + "==DAUN MURBEI==" + daunmurbei[i]); + } + } + + //method sirih merah + public static void sirihmerah() { + String sirihmerah[] = {"\nKANDUNGAN SIRIH MERAH:\n1.Allyprokatekol\n2.Alkaloid\n3.Cineole\n4.Extragol\n5.Eugenol\n6.Fenil propoda\n7.Minyak atsiri", "MANFAAT:\n1.Mengobati Mata merah\n2.Mengobati gusi berdarah\n3.Mengobati penyakit bronkitis\n4.Mengobati darah tinggi\n5.Mengobati batuk\n6.Mengobati tumor\n7.Mengobati diabetes", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN DAUN SIRIH MERAH:\n1.Sirih merah secukupnya\n2.Air secukupnya", "CARA MEMBUAT SEDUHAN DAUN SIRIH MERAH:\n1.Siapkan sirih merah\n2.Rebus Air hingga mendidih\n3.Kemudain masukan sirih merah ke dalam air mendidih\n4.Saring air seduhan sirih merah dan tuangkan ke dalam gelas\n5.Air seduhan sirih merah siap diminum"}; + for (int i = 0; i < sirihmerah.length; i++) { + System.out.println(ANSI_BLUE + "==SIRIH MERAH==" + sirihmerah[i]); + } + } + + //method daun asam + public static void daunasam() { + String daunasam[] = {"\nKANDUNGAN DAUN ASAM:\n1.Flavanoid\n2.Asam askorbat\n3.Tanin\n4.Vitamin C", "MANFAAT:\n1.Sebagai obat asma\n2.Sebagai obat batuk kering\n3.Mengobati malaria\n4.Menyembuhkan peradangan\n5.Mencegah penyakit kuning", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN DAUN ASAM:\n1.Segenggam daun asam\n2.Lima ruas kunyit\n3.Air secukupnya", "CARA MEMBUAT SEDUHAN DAUN ASAM:\n1.Tumbuk 1 genggam daun asam dan 5 ruas kunyit\n2.Rebus dengan air 300 cc hinggan menjadi 200 cc\n3.Kemudian tuangkan kedalam gelas\n4.Supaya lebih nikmat tambahkan gula aren secukupnya\n5.Diamkan hingga dingin lalu minum"}; + for (int i = 0; i < daunasam.length; i++) { + System.out.println(ANSI_GREEN + "==DAUN ASAM==" + daunasam[i]); + } + } + + //method alang-alang + public static void alangalang() { + String alangalang[] = {"\nKANDUNGAN ALANG-ALANG:\n1.Silindrin\n2.Isoarbolinol\n3.Simiarenol\n4.Fernenol\n5.Arundoin\n6.Asam klorogenat\n7.Katekol\n8.Asam Isoklorogenat\n9.Asam oksalat\n10.Asam asetat\n11.Asam sitrat", "MANFAAT:\n1.Sebagai obat asma\n2.Mengobati hepatitis\n3.Mengobati diare\n4.Penyakit jantung\n5.Infeksi ginjal\n6.Demam\n7.Hipertensi", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN ALANG-ALANG:\n1.Air mineral 2 gelas\n2.Alang-alang secukupnya", "CARA MEMBUAT SEDUHAN ALANG-ALANG:\n1.Siapkan alang-alang secukupnya\n2.Cuci terlebih dulu alang-alang hingga bersih\n3.Potong kecil alang-alang\n4.Rebus hingga mendidih\n5.Terakhir angkat, diinginkan dan saring ampasnya\n6.Air rebusan alang-alang siap diminum"}; + for (int i = 0; i < alangalang.length; i++) { + System.out.println(ANSI_RED + "==ALANG-ALANG==" + alangalang[i]); + } + } + + //method daun tempuyung + public static void dauntempuyung() { + String dauntempuyung[] = {"\nKANDUNGAN DAUN TEMPUYUNG:\n1.Flavanoid\n2.Taraksasterol\n3.Inositol\n4.Kumarin\n5.Asam fenolat", "MANFAAT:\n1.Mengobati kencing batu\n2.Mengobati asam urat\n3.Mengobati wasir\n4.Mengobati wasir", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN DAUN TEMPUYUNG:\n1.Air mineral\n2.Daun tempuyung secukupnya", "CARA MEMBUAT SEDUHAN DAUN TEMPUYUNG:\n1.Siapkan daun tempuyung yang masih segar\n2.Cuci terlebih dahulu hingga bersih\n3.Seduh hingga medidih\n4.Saring dan kemudian dinginkan\n5.Air daun tempuyung siap diminum"}; + for (int i = 0; i < dauntempuyung.length; i++) { + System.out.println(ANSI_PURPLE + "==DAUN TEMPUYUNG==" + dauntempuyung[i]); + } + } + + //method daun andong + public static void daunandong() { + String daunandong[] = {"\nKANDUNGAN DAUN ANDONG:\n1.Saponin\n2.Tanin\n3.Flavonoid\n4.Polifenol\n5.Steroida\n6.Kalsium oksalat\n7.Zat besi", "MANFAAT:\n1.Mengobati radang gusi\n2.Mengobati diare\n3.Mengobati wasir", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT DAUN TEMPUYUNG:\n1.Air mineral\n2.Daun andong secukupnya", "CARA MEMBUAT SEDUHAN DAUN ANDONG:\n1.Siapkan daun andong yang masih segar\n2.Cuci hingga bersih\n3.Masukan daun andong kemudian rebus hingga mendidih\n4.Saring daun andong dan dinginkan\n5.Air daun andong siap untuk diminum"}; + for (int i = 0; i < daunandong.length; i++) { + System.out.println("==DAUN ANDONG==" + daunandong[i]); + } + } + + //method temu giring + public static void temugiring() { + String temugiring[] = {"\nKANDUNGAN TEMU GIRING:\n1.Tannin\n2.Minyak atsiri\n3.Flavonoida\n4.Piperazin sitrat\n5.Damar\n6.Kurkumin\n7.Protein\n8.Lemak", "MANFAAT:\n1.Mengobati cacingan\n2.Obat sakit perut\n3.Mengobati cacar air\n4.Mengobati kudis", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT JAMU TEMU GIRING:\n1.Air mineral\n2.Temu giring\n3.Madu", "CARA MEMBUAT JAMU TEMU GIRING:\n1.Cuci temu giring hingga bersih\n2.Parut temu ginring hingga halus\n3.Masukan hasil arutan kedalam gelas\n4.Rebus air hingga mendidih\n5.Tuangkan air ke dalam gelas yang berisi hasil parutan temu giring\n6.Saring dan tambahkan madu supaya lebih nikmat\n7.Jamu temu giring siap diminum"}; + for (int i = 0; i < temugiring.length; i++) { + System.out.println("==TEMU GIRING==" + temugiring[i]); + } + } + + //method akar wangi + public static void akarwangi() { + String akarwangi[] = {"\nKANDUNAGN AKAR WANGI:\n1.Senyawa karbonil\n2.Ester\n3.Vetiveron\n4.Seskuiterpen\n5.Seskuiterpen derivatif", "MANFAAT:\n1.Mengatasi bau mulut\n2.Mengobati rematik\n3.Mengobati batu ginjal\n4.Menurunkan demam", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN AKAR WANGI:\n1.Akar wangi secukupnya\n2.Air secukupnya\n3.Garam", "CARA MEMBUAT SEDUHAN AKAR WANGI:\n1.Cuci terlebih dahulu akar wangi\n2.Potong-potong akar wangi, rebus dengan air sampai mendidih\n3.Masukan garam secukupnya\n4.Tunggu hingga air mengeluarkan wangi\n5.Tuangkan air di gelas tunggu hingga hangat\n6.Air akar wangi siap untuk diminum"}; + for (int i = 0; i < akarwangi.length; i++) { + System.out.println(ANSI_GREEN + "==AKAR WANGI==" + akarwangi[i]); + } + } + + + String[] datatumbuhan = {"Jahe", "Kunyit", "Daun jabu biji", "Temulawak", "Sambiloto", "Kijibeling", "Kumis kucing", "Pegagan", + "Daun cincau", "Lidah buaya", "Daun beluntas", "Belimbing wuluh", "Brotowali", "Daun jinten", "Kayu manis", "Seledri", "Daun kelor", + "Daun murbei", "Sirih merah", "Daun asam", "Alang-Alang", "Daun tempuyung", "Daun andong", "Temu giring", "Akar wangi"}; + + + public void Bubblesort(String []data) { + String[] datatumbuhan=data; + String temp; +// System.out.println("tanaman belum diurutkan di urutkan"); + + System.out.println("====================================="); + +// System.out.println("tanaman sudah diurutkan"); +//// for (int i = 0; i < datatumbuhan.length; i++) { +//// System.out.println(i+1+""+datatumbuhan[i]+""); +//// } + for (int i = 0; i < datatumbuhan.length-1; i++) { + for (int j = 0; j < datatumbuhan.length-1; j++) { + if (datatumbuhan[j].compareTo(datatumbuhan[j+i])>0) { + temp=datatumbuhan[j+1]; + datatumbuhan[j+1]=datatumbuhan[j]; + datatumbuhan[j]=temp; + } + } + } + + + } + public static void display(String []a){ + for (int i = 0; i < a.length; i++) { + System.out.println((i+1)+" " + a[i]); + } + } + public void daftar() { + int data; + int pilih; + String cari; + String ulang2; + try { + do { + String ulang; + BufferedReader a = new BufferedReader(new InputStreamReader(System.in)); + System.out.println("Selamat datang di aplikasi tanaman TOGA"); + System.out.println(ANSI_BLUE + "1.Silahkan pilih daftar tumbuhan\n" + ANSI_RED + "2.Pencaharian berdasarkan penyakit\n"+"3.Sorting berdasarkan abjad"); + System.out.print("Silahkan dipilih: "); + data = Integer.parseInt(a.readLine()); + do { + //kode ketika memilih pilihan 1 + if (data == 1) { +// String[] datatumbuhan = {"Jahe", "Kunyit", "Daun jabu biji", "Temulawak", "Sambiloto", "Kijibeling", "Kumis kucing", "Pegagan", +// "Daun cincau", "Lidah buaya", "Daun beluntas", "Belimbing wuluh", "Brotowali", "Daun jinten", "Kayu manis", "Seledri", "Daun kelor", +// "Daun murbei", "Sirih merah", "Daun asam", "Alang-Alang", "Daun tempuyung", "Daun andong", "Temu giring", "Akar wangi"}; + for (int i = 0; i < datatumbuhan.length; i++) { + System.out.println((i + 1) + ". " + datatumbuhan[i]); + } +// System.out.println("1.Jahe"); +// System.out.println("2.Kunyit"); +// System.out.println("3.Daun jambu biji"); +// System.out.println("4.Temulawak"); +// System.out.println("5.Sambiloto"); +// System.out.println("6.Kijibeling"); +// System.out.println("7.Kumis kucing"); +// System.out.println("8.Pegagan"); +// System.out.println("9.Daun cincau"); +// System.out.println("10.Lidah buaya"); +// System.out.println("11.Daun beluntas"); +// System.out.println("12.Belimbing wuluh"); +// System.out.println("13.Brotowali"); +// System.out.println("14.Daun jinten"); +// System.out.println("15.Kayu manis"); +// System.out.println("16.Seledri"); +// System.out.println("17.Daun kelor"); +// System.out.println("18.Daun murbei"); +// System.out.println("19.Sirih merah"); +// System.out.println("20.Daun asam"); +// System.out.println("21.Alang-alang"); +// System.out.println("22.Daun tempuyung"); +// System.out.println("23.Daun andong"); +// System.out.println("24.Temu giring"); +// System.out.println("25.Akar wangi"); + System.out.print(ANSI_BLUE + "Silahkan pilih daftar tumbuhan diatas:"); + pilih = input.nextInt(); + System.out.println(""); + //kode memilih tanaman herbal menggunakan angka + switch (pilih) { + case 1: + jahe(); + break; + case 2: + kunyit(); + break; + case 3: + daunjambubiji(); + break; + case 4: + temulawak(); + break; + case 5: + sambiloto(); + break; + case 6: + kijibeling(); + break; + case 7: + kumiskucing(); + break; + case 8: + pegagan(); + break; + case 9: + dauncincau(); + break; + case 10: + lidahbuaya(); + break; + case 11: + daunbeluntas(); + break; + case 12: + belimbingwuluh(); + break; + case 13: + brotowali(); + break; + case 14: + daunjinten(); + break; + case 15: + kayumanis(); + break; + case 16: + seledri(); + break; + case 17: + daunkelor(); + break; + case 18: + daunmurbei(); + break; + case 19: + sirihmerah(); + break; + case 20: + daunasam(); + break; + case 21: + alangalang(); + break; + case 22: + dauntempuyung(); + break; + case 23: + daunandong(); + break; + case 24: + temugiring(); + break; + case 25: + akarwangi(); + break; + } + } + //kode ketika memilih pilihan ke-2 + if (data == 2) { + System.out.println("Silahkan masukan keluhan kesehatan yang ingin anda cari"); + String nilai = a.readLine(); + System.out.println(""); + if (nilai.equals("Batuk") || nilai.equals("batuk")) { + kumiskucing(); + System.out.println(""); + System.out.println(""); + belimbingwuluh(); + System.out.println(""); + System.out.println(""); + daunjinten(); + System.out.println(""); + System.out.println(""); + seledri(); + System.out.println(""); + System.out.println(""); + sirihmerah(); + System.out.println(""); + System.out.println(""); + daunasam(); + + } else if (nilai.equals("Malaria") || nilai.equals("malaria")) { + sambiloto(); + System.out.println(""); + System.out.println(""); + daunasam(); + } else if (nilai.equals("Diabetes") || nilai.equals("diabetes")) { + kayumanis(); + System.out.println(""); + System.out.println(""); + daunjambubiji(); + System.out.println(""); + System.out.println(""); + kumiskucing(); + System.out.println(""); + System.out.println(""); + brotowali(); + System.out.println(""); + System.out.println(""); + daunkelor(); + System.out.println(""); + System.out.println(""); + sirihmerah(); + } else if (nilai.equals("Darah Tinggi") || nilai.equals("darah tinggi") || nilai.equals("Hipertensi") || nilai.equals("hipertensi")) { + daunbeluntas(); + System.out.println(""); + System.out.println(""); + seledri(); + System.out.println(""); + System.out.println(""); + dauncincau(); + System.out.println(""); + System.out.println(""); + daunmurbei(); + System.out.println(""); + System.out.println(""); + alangalang(); + } else if (nilai.equals("Asma") || nilai.equals("asma")) { + daunjinten(); + System.out.println(""); + System.out.println(""); + seledri(); + System.out.println(""); + System.out.println(""); + daunasam(); + System.out.println(""); + System.out.println(""); + alangalang(); + } else if (nilai.equals("Alergi") || nilai.equals("alergi")) { + jahe(); + System.out.println(""); + System.out.println(""); + kumiskucing(); + } else if (nilai.equals("Komedo") || nilai.equals("komedo")) { + daunjambubiji(); + } else if (nilai.equals("Gagal ginjal") || nilai.equals("gagal ginjal")) { + kijibeling(); + } else if (nilai.equals("Sariawan") || nilai.equals("sariawan")) { + pegagan(); + System.out.println(""); + System.out.println(""); + belimbingwuluh(); + } else if (nilai.equals("Kembung") || nilai.equals("kembung")) { + daunjambubiji(); + System.out.println(""); + System.out.println(""); + daunjinten(); + } else if (nilai.equals("Panas dalam") || nilai.equals("panas dalam")) { + pegagan(); + System.out.println(""); + System.out.println(""); + alangalang(); + } else if (nilai.equals("Sembelit") || nilai.equals("sembelit")) { + kumiskucing(); + System.out.println(""); + System.out.println(""); + seledri(); + } else if (nilai.equals("Tumor") || nilai.equals("tumor")) { + sirihmerah(); + } else if (nilai.equals("Bronkitis") || nilai.equals("bronkitis")) { + sirihmerah(); + } else if (nilai.equals("Mata merah") || nilai.equals("mata merah")) { + sirihmerah(); + } else if (nilai.equals("Diare") || nilai.equals("diare")) { + kunyit(); + System.out.println(""); + System.out.println(""); + daunjambubiji(); + System.out.println(""); + System.out.println(""); + kijibeling(); + System.out.println(""); + System.out.println(""); + alangalang(); + System.out.println(""); + System.out.println(""); + daunandong(); + } else if (nilai.equals("Hepatitis") || nilai.equals("hepatitis")) { + daunmurbei(); + System.out.println(""); + System.out.println(""); + sambiloto(); + System.out.println(""); + System.out.println(""); + daunasam(); + System.out.println(""); + System.out.println(""); + temulawak(); + System.out.println(""); + System.out.println(""); + alangalang(); + System.out.println(""); + System.out.println(""); + dauntempuyung(); + } else if (nilai.equals("Radang") || nilai.equals("radang")) { + kunyit(); + System.out.println(""); + System.out.println(""); + belimbingwuluh(); + } else if (nilai.equals("Radang sendi") || nilai.equals("radang sendi")) { + temulawak(); + } else if (nilai.equals("Rematik") || nilai.equals("rematik")) { + jahe(); + System.out.println(""); + System.out.println(""); + daunbeluntas(); + System.out.println(""); + System.out.println(""); + brotowali(); + System.out.println(""); + System.out.println(""); + kayumanis(); + System.out.println(""); + System.out.println(""); + akarwangi(); + } else if (nilai.equals("Wasir") || nilai.equals("wasir")) { + lidahbuaya(); + System.out.println(""); + System.out.println(""); + dauntempuyung(); + System.out.println(""); + System.out.println(""); + daunandong(); + } else if (nilai.equals("Anemia") || nilai.equals("anemia")) { + seledri(); + System.out.println(""); + System.out.println(""); + daunkelor(); + } else if (nilai.equals("Kanker") || nilai.equals("kanker")) { + jahe(); + System.out.println(""); + System.out.println(""); + temulawak(); + System.out.println(""); + System.out.println(""); + kijibeling(); + System.out.println(""); + System.out.println(""); + dauncincau(); + System.out.println(""); + System.out.println(""); + belimbingwuluh(); + System.out.println(""); + System.out.println(""); + seledri(); + } else if (nilai.equals("Jantung") || nilai.equals("jantung")) { + kayumanis(); + System.out.println(""); + System.out.println(""); + alangalang(); + } else if (nilai.equals("Stroke") || nilai.equals("stroke")) { + daunjinten(); + } else if (nilai.equals("Demam") || nilai.equals("demam")) { + sambiloto(); + System.out.println(""); + System.out.println(""); + pegagan(); + System.out.println(""); + System.out.println(""); + dauncincau(); + System.out.println(""); + System.out.println(""); + brotowali(); + System.out.println(""); + System.out.println(""); + daunjinten(); + System.out.println(""); + System.out.println(""); + daunkelor(); + System.out.println(""); + System.out.println(""); + alangalang(); + System.out.println(""); + System.out.println(""); + akarwangi(); + } else if (nilai.equals("Keputihan") || nilai.equals("keputihan")) { + daunbeluntas(); + } else if (nilai.equals("TBC") || nilai.equals("tbc")) { + daunbeluntas(); + } else if (nilai.equals("Sakit gigi") || nilai.equals("sakit gigi")) { + sambiloto(); + } else if (nilai.equals("Maag") || nilai.equals("maag")) { + kunyit(); + } else if (nilai.equals("Kencing batu") || nilai.equals("kencing batu")) { + dauntempuyung(); + } else if (nilai.equals("Asam urat") || nilai.equals("asam urat")) { + dauntempuyung(); + } else if (nilai.equals("Radang gusi") || nilai.equals("radang gusi")) { + daunandong(); + } else if (nilai.equals("Cacingan") || nilai.equals("cacingan")) { + daunkelor(); + System.out.println(""); + System.out.println(""); + temugiring(); + } else if (nilai.equals("Sakit perut") || nilai.equals("sakit perut")) { + dauncincau(); + System.out.println(""); + System.out.println(""); + temugiring(); + } else if (nilai.equals("Cacar air") || nilai.equals("cacar air")) { + temugiring(); + } else if (nilai.equals("Bau mulut") || nilai.equals("bau mulut")) { + akarwangi(); + } else if (nilai.equals("Batu ginjal") || nilai.equals("batu ginjal")) { + akarwangi(); + } else { + System.out.println("TIDAK ADA DI DAFTAR PENCAHARIAN"); + } + } + if (data == 3) { + String[] datatum= datatumbuhan; + System.out.println("Sorting berdasarkan abjad"); + Bubblesort(datatum); + display(datatum); + + } + System.out.println(""); + //kode pengulangan ke halaman yang tadi + System.out.println("apakah anda ingin kembali lagi?y/n"); + ulang = input.next(); + } while (ulang.equals("y") || ulang.equals("Y")); + //kode pengulangan ke halaman home + System.out.println("apakah anda mau kembali ke home?y/n"); + ulang2 = input.next(); + } while (ulang2.equals("y") || ulang2.equals("Y")); + System.out.println(">>>>>>>>>>>>>>>TERIMA KASIH<<<<<<<<<<<<<<<"); + System.out.println("Semoga sehat selalu"); + System.out.println("Copyright Lexy sekeluarga"); + } catch (Exception e) { + System.out.println("Masukan inputan dengan benar"); + System.out.println(""); + daftar(); + } + } + + public static void main(String[] args) { + Project_UAS2 oke= new Project_UAS2(); + try { + oke.daftar(); + } catch (Exception e) { + System.out.println("salah"); + + } + + } + +} diff --git a/project_UAS2/src/project_uas2/UrutanString.java b/project_UAS2/src/project_uas2/UrutanString.java new file mode 100644 index 00000000..ae0a773c --- /dev/null +++ b/project_UAS2/src/project_uas2/UrutanString.java @@ -0,0 +1,38 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package project_uas2; + +/** + * + * @author USER + */ +public class UrutanString { + public static void main(String[] args) { + String[] nama = {"Jahe", "Kunyit", "Daun jabu biji", "Temulawak", "Sambiloto", "Kijibeling", "Kumis kucing", "Pegagan", + "Daun cincau", "Lidah buaya", "Daun beluntas", "Belimbing wuluh", "Brotowali", "Daun jinten", "Kayu manis", "Seledri", "Daun kelor", + "Daun murbei", "Sirih merah", "Daun asam", "Alang-Alang", "Daun tempuyung", "Daun andong", "Temu giring", "Akar wangi"}; + String temp; + + System.out.println("nama sebelum diurutkan"); + for (int i = 0; i < nama.length; i++) { + System.out.println(i+1+" "+nama[i]+""); + } + System.out.println("========================================="); + System.out.println("nama yang sudah diurutkan"); + for (int i = 0; i < (nama.length-1); i++) { + for (int j = 0; j < nama.length-1; j++) { + if (nama[j].compareTo(nama[j+1])>0) { + temp=nama[j+1]; + nama[j+1]=nama[j]; + nama[j]=temp; + } + } + } + for (int i = 0; i < nama.length; i++) { + System.out.println(i+1+" "+nama[i]); + } + } +} diff --git a/project_UAS2/src/project_uas2/project_UAS2_shellshort.java b/project_UAS2/src/project_uas2/project_UAS2_shellshort.java new file mode 100644 index 00000000..53746a1f --- /dev/null +++ b/project_UAS2/src/project_uas2/project_UAS2_shellshort.java @@ -0,0 +1,662 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package project_uas2; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.Scanner; + +/** + * + * @author USER + */ +public class project_UAS2_shellshort { + String data; + String cari = ""; + int jumlah = 0; + public static Scanner input = new Scanner(System.in); + //kode warna merah + public static String ANSI_RED = "\u001B[31m"; + //kode warna hijau + public static String ANSI_GREEN = "\u001B[32m"; + //kode warna ungu + public static String ANSI_PURPLE = "\u001B[35m"; + //kode warna kuning + public static String ANSI_YELLOW = "\u001B[33m"; + //kode warna biru + public static String ANSI_BLUE = "\u001B[34m"; + + //method jahe + public static void jahe() { + String jahe[] = {"\nKANDUNGAN JAHE\n1.Minyak atsiri zingiberena (zingirona)\n2.zingiberol\n3.kurkumen\n4.gingerol\n5.filandrena\n6.resin pahit\n7.bisabolena", "MANFAAT:\n1.Menghangatkan badan\n2.menuruntkan berat badan\n3.menjaga kondisi jantung\n4.mengatasi mabuk perjalanan\n5.mengatasi gangguan pencernaan\n6.mencegah kanker usus\n7.mengobati sakit kepala\n8.mengomati alergi\n9.mengobati penyakit rematik\n10.meningkatkan sistem kekebalan tubuh", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT WEDANG JAHE:\n1.Jahe\n2.Gula pasir atau gula merah(Sesuai selera)\n3.Air", "CARA MEMBUAT WEDANG JAHE:\n1.kupas dan cuci jahe hingga bersih\n2.Rebus air hingga mendidih\n3.Sembari menunggu air mendidih, jahe dibakar sampai kemerah-merahan\n4.Kupas bagian yang terbakar\n5.Potong kecil-kecil dan dipukul agar aromanya keluar\n6.Masukan jahe yang telah di pukul ke dalam gelas\n7. Masukan gula secukupnya kedalam gelas\n8.Tuangkan air yang sudah dimasak tadi aduk hingga rata\n9.Hidangkan saat masih panas"}; + for (int i = 0; i < jahe.length; i++) { + System.out.println(ANSI_RED + "==JAHE==" + jahe[i]); + + } + } + + //method kunyit + public static void kunyit() { +String kunyit[] = {"\nKANDUNGAN KUNYIT:\n1.kurkumin\n2.desmetoksikumin\n3.bisdesmetoksikurkumin\n4.Keton sesquiterpen\n5.turmeron\n6.Zingiberen", "MANFAAT:\n1.Sebagai ramuan anti peradangan tubuh\n2.Mengobati penyakit asam lambung\n3.Mengurangi gas pada pencernaan\n4.Meredakan sakit akibat irritable bowel syndrom\n5.Mengurangi mual\n6.Meredakan diare", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT JAMU KUNYIT:\n1.Empat gelas air\n2.Satu sendok teh kunyit parutan kunyit\n3.Lemon atau madu untuk ditambahkan pada tahap akhir", "CARA MEMBUAT JAMU KUNYIT:\n1.Rebus 4 gelas air sampai mendidih\n2.Masukkan 1 sendok teh kunyit ke air yang sedang mendidih\n3.Kecilkan api dan biarkan air yang sudah dicampur kunyit tersebut mendidih selama sekitar 10 menit\n4.Matikan api dan saring air kunyit tersebut menggunakan saringan yang halus\n5.Tuangkan hasil saringan tersebut ke dalam gelas dan tambahkan lemon atau madu sesuai selera"}; + for (int i = 0; i < kunyit.length; i++) { + System.out.println(ANSI_GREEN + "==KUNYIT==" + kunyit[i]); + } + } + + //method daun jambu biji + public static void daunjambubiji() { + String daunjambubiji[] = {"\nKANDUNGAN DAUN JAMBU BIJI:\n1.Saponin\n2.Flavanoid\n3.Polifenol\n4.Alkaloid\n5.Karoten\n6.Steroid\n7.Kuinon\n8.Anti-oksidan\n9.Minyak atsiri\n10.Tannin\n11.Senyawa anti-mutagenic", "MANFAAT:\n1.Mengobati diare dan disentri\n2.Diabetes Mellitus\n3.Mengobati Luka Memar\n4.Mengatasi Jerawat\n5.Mengatasi Komedo\n6.Ambeien\n7.Mengusir kembung", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN JAMBU BIJI:\n1.Siapkan 7-10 lembar daun jambu biji\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN JAMBU BIJI:\n1.Cuci bersih daun tersebut dalam air yang mengalir\n2.Rebus 2-3 gelas air minum, setelah mendidih masukan daun jambu biji terlebus\n3.Rebus hingga air tersisa setengahnya sambil sesekali di aduk\n4.Setelah dingin ramuan air rebusan siap untuk di minum"}; + for (int i = 0; i < daunjambubiji.length; i++) { + System.out.println(ANSI_PURPLE + "==DAUN JAMBU BIJI==" + daunjambubiji[i]); + } + } + + //method temulawak + public static void temulawak() { + String temulawak[] = {"\nKANDUNGAN TEMULAWAK:\n1.Magnesium\n2.Phosphorus\n3.Zinc\n4.Asam folat\n5.Vitamin A\n6.Vitamin D", "MANFAAT:\n1.Memelihara Fungsi Hati\n2.Mengurangi radang sendi\n3.Masalah pencernaan\n4.Membantu Menurunkan Lemak Darah\n5.Melawan Kanker", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT JAMU TEMULAWAK:\n1.satu jari, rimpang temulawak iris-iris\n2.Sepuluh lembar, daun ungu\n3.Sstu gelas air putih 200ml", "CARA MEMBUAT JAMU TEMULAWAK:\n1.Bersihkan rimpang temulawak dengan daun ungu hingga bersih\n2.Setelah itu, rebus kedua bahan tersebut hingga mendidih\n3.Kemudian, angkat dan dinginkan lalu sharing\n4.Minum ramuan tersebut secara rutin 2 kali sehari sebanyak setengah gelas"}; + for (int i = 0; i < temulawak.length; i++) { + System.out.println(ANSI_YELLOW + "==TEMULAWAK==" + temulawak[i]); + } + } + + //method sambiloto + public static void sambiloto() { + String sambiloto[] = {"\nKANDUNGAN SAMBILITO:\n1.Andrographolide\n2.Saponin\n3.Falvonoid\n4.Alkanoid\n5.Tanin\n6.Laktone\n7.Panikulin\n8.Kalmegin\n9.Hablur kuning", "MANFAAT:\n1.Dapat mengobati hepatitis\n2.Mengobati disentri basiler\n3.Mengobati sakit gigi\n4.Mengobati demam\n5.Mengobati Malaria", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN SAMBILOTO:\n1.Daun sambiloto\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN SAMBILOTO:\n1.Daun sambiloto segar sebanyak satu genggam\n2.Ditumbuk rata kemudian ditambahkan air matang sebanyak 110mL\n3.Saring kemudian minum sekaligus"}; + for (int i = 0; i < sambiloto.length; i++) { + System.out.println(ANSI_BLUE + "==SAMBILOTO==" + sambiloto[i]); + } + } + + //method kijibeling + public static void kijibeling() { + String kijibeling[] = {"\nKANDUNGAN KIJIBELING:\n1.Tripenoid\n2.Fosfor\n3.Natrium\n4.Kafein\n5.Kalsium\n6.Asam silikat\n7.Potassium", "MANFAAT:\n1.Menjaga kesehatan ginjal\n2.Diuretic alami\n3.Meningkatkan volume darah\n4.Mempercepat proses pembekuan darah\n5.Menghambat pertumbuhan kanker\n6.Mengatasi diare serta disentri\n7.Menjaga kesehatan organ hati\n8.Menurunkan kolestrol", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN KIJIBELING:\n1.Siapkan daun kijibeling sekitar 5-6 lembar\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN KIJIBELING:\n1.Rebus air bersamaan dengan daun kijibeling\n2.Tunggu hingga air setengah\n3.Setelah itu, angkat dan dinginkan\n4.Setelah dingin, minum ramuan tersebut dua kali sehari"}; + for (int i = 0; i < kijibeling.length; i++) { + System.out.println(ANSI_RED + "==KIJIBELING==" + kijibeling[i]); + } + } + + //method kumis kucing + public static void kumiskucing() { + String kumiskucing[] = {"\nKADUNGAN TUMBUHAN KUMIS KUCING:\n1.Garam kalium\n2.Glikosida Orthosiphonim\n3.Mioinositol\n4.Minyak Atsiri\n5.Saponin\n6.Sapofonim\n7.Sinensetis\n8.Zat samak", "MANFAAT:\n1.Melancarkan air seni\n2.Mengobati batuk\n3.Mengobati sembelit\n4.Mengobati diabetes\n5.Mengobati gatal karena alergi", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN TUMBUHAN KUMIS KUCING:\n1.Siapkan 90 gr daun kumis kucing segar\n2.Satu gelas air putih", "CARA MEMBUAT AIR SEDUHAN DAUN TUMBUHAN KUMIS KUCING:\n1.Cuci daun kumis kucing sampai bersih\n2.Rebus daun kumis kucing tersebut dengan air hingga airnya tersisa 1/2 gelas saja\n3.Minum ramuan tersebut sebanyak 3x sehari dengan dosis 1/2 gelas"}; + for (int i = 0; i < kumiskucing.length; i++) { + System.out.println(ANSI_GREEN + "==KUMIS KUCING==" + kumiskucing[i]); + } + } + + //method pegagan + public static void pegagan() { + String pegagan[] = {"\nKANDUNGAN PEGAGAN:\n1.brahmoside\n2.brahmic acid\n3.brahminosid\n4.asiaticoside\n5.madecassoside\n6.madasiatic acid\n7.centelloside", "MANFAAT:\n1.Mengobati sariawan dan panas dalam\n2.Menghilangkan jerawat dan menghaluskan wajah\n3.Sebagai pembersih alami\n4.Melancarkan sirkulasi darah\n5.Menurunkan demam\n6.Meningkatkan tenaga dan stamina tubuh\n7.Meningkatkan sistem saraf ingatan", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN PEGAGAN\n1.Satu genggam daun pegagan\n2.Lima batang tapak lima\n3.Setengah genggam, daun jintan hitam\n4. Satu sendok madu\n5. Satu gelas air putih 200mL", "CARA MEMBUAT SEDUHAN DAUN PEGAGAN:\n1.Cuci bersih semua bahan, lalu masukan dalam panci bersama satu gelas air\n2.Setelah itu rebus hingga mendidih\n3.Selanjutnya saring ainya dan beri campuran madu, aduk sampai rata\n4.Angkat dan minum air ramuan tersebut secara rutin sehari 2 kali pagi dan sore"}; + for (int i = 0; i < pegagan.length; i++) { + System.out.println(ANSI_PURPLE + "==PEGAGAN==" + pegagan[i]); + } + } + + //method daun cincau + public static void dauncincau() { + String dauncincau[] = {"\nKANDUNGAN DAUN CINCAU:\n1.Serat Makanan\n2.Fosfor\n3.Vitamin A\n4.Vitamin B1\n5.Vitamin C\n6.Protein\n7.Lemak\n8.Karbohidrat\n9.Energi", "MANFAAT:\n1.Mengobati sakit perut dan tekanan darah tinggi\n2.Mengobati demam\n3.Mengobati penyakit kanker", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT CINCAU:\n1.Air matang 300 mL\n2.Daun cincau 40 lembar yang sedang, cuci bersih", "CARA MEMBUAT CINCAU:\n1.Petama-tama remas-remas daun cincau segar\n2.Tuanglah 1/2 bagian air sedikit demi sedikit sambil terus diremas-remas sampai keluar lendir/gel berwarna hijau\n3.Selanjutnya saring remasan daun cincau\n4.Kemudian remas-remas kembali ampas (daun cincau) sambil tuang sisa air sampai keluar lendirnya. Setelah itu saring\n5.Nah sekarang simpan hasil saringan daun cincau dalam lemari pendingin sampai beku selama kurang lebih 3-4 jam\n6.Cincau hijau siap digunakan, bisa diolah lanjutan menjadi es cincau segar"}; + for (int i = 0; i < dauncincau.length; i++) { + System.out.println(ANSI_YELLOW + "==DAUN CINCAU==" + dauncincau[i]); + } + } + + //method lidah buaya + public static void lidahbuaya() { + String lidahbuaya[] = {"\nKANDUNGAN LIDAH BUAYA:\n1.Energi\n2.Protein\n3.Karbohidrat\n4.Kalsium\n5.Zat besi\n6.Vitamin A\n7.Vitamin B\n8.Vitamin C\n8.Fosfor", "MANFAAT:\n1.Penyubur rambut\n2.Sebagai anti oksidan\n3.Menghilangkan ketombe\n4.Detoksifikasi\n5.Menjaga kesehatan mulut\n6.Menjaga berat badan\n7.Mengobati wasir\n8.Menghilangkan jerawat", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT NATA DE ALOE VERA:\n1.Daun lidah buaya\n2.Garam\n3.Air", "CARA MEMBUAT NATA DE ALOE VERA:\n1.Daun lidah buaya dipotong sekitar per 10 cm menjadi 5 potong\n2.Hilangkan kulit yang berwarna hijau, tinggalkan dagaing ynag berwarna bening\n3.Dari potongan memanjang potong lagi menjadi kotak-kotak seperti nata de coco\n4.Kemudian cuci berulang-ulang sampai lendirnya habis\n5.Tambahkan garam dalam pencucian mungkin 2 sampai 3 kali saat membilasnya\n6.Kemudian rebuslah, tunggu 15 menit selama mendidih, setelah itu angkat, untuk mengurangi bau dapat ditambahkan daun pandan"}; + for (int i = 0; i < lidahbuaya.length; i++) { + System.out.println(ANSI_BLUE + "==LIDAH BUAYA==" + lidahbuaya[i]); + } + } + + //method daun beluntas + public static void daunbeluntas() { + String daunbeluntas[] = {"\nKANDUNGAN DAUN BELUNTAS:\n1.Alkanoid\n2.Pluchine\n3.Asam kafeoilkuniat\n4.Saponin\n5.polifenol\n6.Tannin\n7.Asam amino\n8.Kalsium\n9.Fosfor\n10.Vitamin A\n11.Vitamin C", "MANFAAT:\n1.Mengobati pencernaan pada anak-anak\n2.Mengatasi TBC kelenjar leher\n3.Mengatasi nyeri rematik\n4.Menghilangkan bau badan dan bau mulut\n5.Obat keputihan\n6.Mengatasi masalah hipertensi\n7.Melancarkan haid", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN BELUNTAS:\n1.Siapkan beberapa helai daun beluntas 3-5 lembar\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN BELUNTAS:\n1.Cuci daun beluntas sampai benar-benar bersih, kemudian rebus dengan 2 gelas air bersih\n2.Tunggu sampai mendidih hingga tersisa 1 gelas\n3.Angkat dan kemudian diamkan sampai menjadi hangat, minumlah secara rutin pagi dan sore hari"}; + for (int i = 0; i < daunbeluntas.length; i++) { + System.out.println(ANSI_PURPLE + "==DAUN BELUNTAS==" + daunbeluntas[i]); + } + } + + //method belimbing wuluh + public static void belimbingwuluh() { + String belimbingwuluh[] = {"\nKANDUNGAN BELIMBING WULUH:\n1.Glukosid\n2.Tanin\n3.Asam folat\n4.Peroksida\n5.Kalsium oksalat\n6.Sulfur\n7.Kalium sitrat", "MANFAAT:\n1.Obat sariawan dan mengatasi gusi berdarah\n2.Melancarkan pencernaan\n3.Menghaluskan kulit wajah\n4.Menyembuhkan batuk\n5.Menyembuhkan gondongan\n6.Mencegah penyakit kanker\n7.Mengatasi hipertensi\n8.Mengatasi rematik", "BAHAN-BAHAN YANG DIPERLUKAN BUAT SIRUP BELIMBING WULUH:\n1.200 gram belimbing wuluh yang segar dan sudah dicuci\n2. Satu setengah air putih\n3.Madu secukupnya\n4.Es batu secukupnya", "CARA MEMBUAT SIRUP BELIMBING WULUH:\n1.Potong kecil-kecil buah belimbing wuluh\n2.Masukan semua bahan ke dalam bender, lalu bender hingga halus\n3.Tuang jus kedalam gelas saji\n4.Jus belimbing siap untuk disajikan"}; + for (int i = 0; i < belimbingwuluh.length; i++) { + System.out.println(ANSI_RED + "==BELIMBING WULUH==" + belimbingwuluh[i]); + } + } + + //method brotowali + public static void brotowali() { + String brotowali[] = {"\nKANDUNGAN BROTOWALI:\n1.Glikosida pikroretosid\n2.Harsa\n3.Berberin\n4.Palmatin\n5.Alkaloid berberin", "MANFAAT:\n1.Mengobati rematik\n2.Mengobati demam kuning\n3.Mengobati diabetes\n4.Mengobati kudis\n5.Mengobati luka", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN AIR BROTOWALI:\n1.6cm batang brotowali\n2.Sepertiga genggam daun kumis kucing\n3.Sepertiga daun sambiloto\n4.Tiga gelas air", "CARA MEMBUAT SEDUAN AIR BROTOWALI:\n1.Cuci bersih dan potong-potong semua herba\n2.Rebuslah semua herba dengan 3 gelas air hingga mendidih dan tersisa 2 gelas air\n3.Setelah dingin, saring dan minum 1 gelas setelah makan 2 kali sehari"}; + for (int i = 0; i < brotowali.length; i++) { + System.out.println(ANSI_YELLOW + "==BROTOWALI==" + brotowali[i]); + } + } + + //method daun jinten + public static void daunjinten() { + String daunjinten[] = {"\nKANDUNGAN DAUN JINTEN:\n1.Minyak atsiri\n2.Fenol\n3.Kalium", "MANFAAT:\n1.Mengembalikan kekebalan tubuh\n2.Obat demam\n3.Mengobati asma\n4.Sebagai obat batuk\n5.Mengobati penyakit stroke\n6.Mengobati rematik\n7.Mengobati perut kembung", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN DAUN JINTEN:\n1.Siapkan 6 lembar daun jinten\n2.Air", "CARA MEMBUAT AIR SEDUHAN DAUN JINTEN:\n1.Cuci bersih daun jinten kemudian tumbuklah sampai halus\n2.Rebuslah air hingga mendidih\n3.Setelah air mendidih angkat kemudian tuangkan air ke dalam gelas yang sudah berisi daun jinten\n4.Air seduhan daun jinten siap dihidangkan"}; + for (int i = 0; i < daunjinten.length; i++) { + System.out.println(ANSI_BLUE + "==DAUN JINTEN==" + daunjinten[i]); + } + } + + //method kayu manis + public static void kayumanis() { + String kayumanis[] = {"\nKANDUNGAN KAYU MANIS:\n1.Eugenol\n2.Minyak atsiri\n3.tanin\n4.Sinamaldehide\n5.Kalsium oksalat\n6.Safrole\n7.Zat penyamak dan damar", "MANFAAT:\n1.Mengurangi rasa nyeri haid\n2.Mencegah terjadinya penggumpalan darah\n3.Mengurangi sakit rematik\n4.Mencegah penyakit jantung\n5.Menghangatkan tubuh\n6.Mengontrol gula darah", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT:\n1.Siapkan 1 batang kayu manis\n2.Madu\n3.Air secukupnya", "CARA MEMBUAT AIR SEDUHAN KAYU MANIS:\n1.Rebuslah air selama kurang lebih 5 menit\n2.Kemudian masukan kayu manis ke dalam air yang direbus\n3.Setelah itu tuangkan ke dalam gelas\n4.Tambahkan madu supaya lebih nikmat\n5.Air seduhan kayu manis siap dihidangkan"}; + for (int i = 0; i < kayumanis.length; i++) { + System.out.println(ANSI_GREEN + "==KAYU MANIS==" + kayumanis[i]); + } + } + + //method seledri + public static void seledri() { + String seledri[] = {"\nKANDUNGAN SELEDRI:\n1.Kalium\n2.Folat\n3.Kalsium\n4.Vitamin K\n5.Serat", "MANFAAT:\n1.Mengobati rematik\n2.Mengobati anemia\n3.Mengobati batuk\n4.Memerangi kanker\n5.Menurunkan tekanan darah tinggi\n6.Mencegah asma\n7.Mencegah sembelit", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT AIR SEDUHAN SELEDRI:\n1.Daun seledri\n2.Air 3 gelas", "CARA MEMBUAT AIR SEDUHAN SELEDRI:\n1.Saipkan daun seledri\n2.Cuci hingga bersih\n3.Kemudian potong-potong\n4.Tuangkan 3 gelas kedalam panci\n5.Masukan daun seledri\n6.Tunggu airnya hingga menjadi 1 gelas:\n7.Air seduhan seledri siap diminum"}; + for (int i = 0; i < seledri.length; i++) { + System.out.println(ANSI_RED + "==SELEDRI==" + seledri[i]); + } + } + + //method daun kelor + public static void daunkelor() { + String daunkelor[] = {"\nKANDUNGAN DAUN KELOR:\n1.Protein\n2.Fosfor\n3.Zat besi\n4.Kalsium\n5.Vitamin B1\n6.Vitamin C\n7.Vitamin A", "MANFAAT:\n1.Antimikroba\n2.Mencegah rematik\n3.Mengobati demam\n4.Mengobati anemia\n5.Mengobati diabetes\n6.Mengobati cacingan", "BAHAN-BAHAN YANG DIPERLUKAN UTNUK MEMBUAT TEH DAUN KELOR:\n1.Daun kelor yang sudah di keringkan\n2.Air secukupnya\n3.Madu", "CARA MEMBUAT TEH DAUN KELOR:\n1.Siapkan daun kelor yang sudah di keringkan\n2.Rebus air hingga mendidih\n3.Kemudian masukan air ke dalam gelas yang sudah berisi daun kelor\n4.Setelah itu saring daun kelor tersebut\n5.Air teh daun kelor siap dihidangkan"}; + for (int i = 0; i < daunkelor.length; i++) { + System.out.println(ANSI_PURPLE + "==DAUN KELOR==" + daunkelor[i]); + } + } + + //method daun murbei + public static void daunmurbei() { + String daunmurbei[] = {"\nKANDUNGAN DAUN MURBEI:\n1.Eugenol\n2.Betahexenal\n3.Benzaidehide\n4.Vitamin A\n5.Vitamin B1\n6.Vitamin C\n7.Karoten", "MANFAAT:\n1.Mengobati tekanan darah tinggi\n2.Mengobati rematik\n3.Mengobati hepatitis kronis\n4.Menggobati gigitan ular\n5.Mengobati jantung lemah", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT TEH MURBEI:\n1.Pucuk daun teh murbei yang sudah kering\n2.Air secukup nya", "CARA MEMBUAT TEH MURBEI:\n1.Siapkan pucuk daun teh murbei yang sudah di keringkan\n2.Rebus air hingga mendidih\n3.Tuangkan air kedalam gelas yang sudah berisi daun murbei\n4.Kemudian saring, dan teh daun murbei sudah siap diminum"}; + for (int i = 0; i < daunmurbei.length; i++) { + System.out.println(ANSI_YELLOW + "==DAUN MURBEI==" + daunmurbei[i]); + } + } + + //method sirih merah + public static void sirihmerah() { + String sirihmerah[] = {"\nKANDUNGAN SIRIH MERAH:\n1.Allyprokatekol\n2.Alkaloid\n3.Cineole\n4.Extragol\n5.Eugenol\n6.Fenil propoda\n7.Minyak atsiri", "MANFAAT:\n1.Mengobati Mata merah\n2.Mengobati gusi berdarah\n3.Mengobati penyakit bronkitis\n4.Mengobati darah tinggi\n5.Mengobati batuk\n6.Mengobati tumor\n7.Mengobati diabetes", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN DAUN SIRIH MERAH:\n1.Sirih merah secukupnya\n2.Air secukupnya", "CARA MEMBUAT SEDUHAN DAUN SIRIH MERAH:\n1.Siapkan sirih merah\n2.Rebus Air hingga mendidih\n3.Kemudain masukan sirih merah ke dalam air mendidih\n4.Saring air seduhan sirih merah dan tuangkan ke dalam gelas\n5.Air seduhan sirih merah siap diminum"}; + for (int i = 0; i < sirihmerah.length; i++) { + System.out.println(ANSI_BLUE + "==SIRIH MERAH==" + sirihmerah[i]); + } + } + + //method daun asam + public static void daunasam() { + String daunasam[] = {"\nKANDUNGAN DAUN ASAM:\n1.Flavanoid\n2.Asam askorbat\n3.Tanin\n4.Vitamin C", "MANFAAT:\n1.Sebagai obat asma\n2.Sebagai obat batuk kering\n3.Mengobati malaria\n4.Menyembuhkan peradangan\n5.Mencegah penyakit kuning", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN DAUN ASAM:\n1.Segenggam daun asam\n2.Lima ruas kunyit\n3.Air secukupnya", "CARA MEMBUAT SEDUHAN DAUN ASAM:\n1.Tumbuk 1 genggam daun asam dan 5 ruas kunyit\n2.Rebus dengan air 300 cc hinggan menjadi 200 cc\n3.Kemudian tuangkan kedalam gelas\n4.Supaya lebih nikmat tambahkan gula aren secukupnya\n5.Diamkan hingga dingin lalu minum"}; + for (int i = 0; i < daunasam.length; i++) { + System.out.println(ANSI_GREEN + "==DAUN ASAM==" + daunasam[i]); + } + } + + //method alang-alang + public static void alangalang() { + String alangalang[] = {"\nKANDUNGAN ALANG-ALANG:\n1.Silindrin\n2.Isoarbolinol\n3.Simiarenol\n4.Fernenol\n5.Arundoin\n6.Asam klorogenat\n7.Katekol\n8.Asam Isoklorogenat\n9.Asam oksalat\n10.Asam asetat\n11.Asam sitrat", "MANFAAT:\n1.Sebagai obat asma\n2.Mengobati hepatitis\n3.Mengobati diare\n4.Penyakit jantung\n5.Infeksi ginjal\n6.Demam\n7.Hipertensi", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN ALANG-ALANG:\n1.Air mineral 2 gelas\n2.Alang-alang secukupnya", "CARA MEMBUAT SEDUHAN ALANG-ALANG:\n1.Siapkan alang-alang secukupnya\n2.Cuci terlebih dulu alang-alang hingga bersih\n3.Potong kecil alang-alang\n4.Rebus hingga mendidih\n5.Terakhir angkat, diinginkan dan saring ampasnya\n6.Air rebusan alang-alang siap diminum"}; + for (int i = 0; i < alangalang.length; i++) { + System.out.println(ANSI_RED + "==ALANG-ALANG==" + alangalang[i]); + } + } + + //method daun tempuyung + public static void dauntempuyung() { + String dauntempuyung[] = {"\nKANDUNGAN DAUN TEMPUYUNG:\n1.Flavanoid\n2.Taraksasterol\n3.Inositol\n4.Kumarin\n5.Asam fenolat", "MANFAAT:\n1.Mengobati kencing batu\n2.Mengobati asam urat\n3.Mengobati wasir\n4.Mengobati wasir", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN DAUN TEMPUYUNG:\n1.Air mineral\n2.Daun tempuyung secukupnya", "CARA MEMBUAT SEDUHAN DAUN TEMPUYUNG:\n1.Siapkan daun tempuyung yang masih segar\n2.Cuci terlebih dahulu hingga bersih\n3.Seduh hingga medidih\n4.Saring dan kemudian dinginkan\n5.Air daun tempuyung siap diminum"}; + for (int i = 0; i < dauntempuyung.length; i++) { + System.out.println(ANSI_PURPLE + "==DAUN TEMPUYUNG==" + dauntempuyung[i]); + } + } + + //method daun andong + public static void daunandong() { + String daunandong[] = {"\nKANDUNGAN DAUN ANDONG:\n1.Saponin\n2.Tanin\n3.Flavonoid\n4.Polifenol\n5.Steroida\n6.Kalsium oksalat\n7.Zat besi", "MANFAAT:\n1.Mengobati radang gusi\n2.Mengobati diare\n3.Mengobati wasir", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT DAUN TEMPUYUNG:\n1.Air mineral\n2.Daun andong secukupnya", "CARA MEMBUAT SEDUHAN DAUN ANDONG:\n1.Siapkan daun andong yang masih segar\n2.Cuci hingga bersih\n3.Masukan daun andong kemudian rebus hingga mendidih\n4.Saring daun andong dan dinginkan\n5.Air daun andong siap untuk diminum"}; + for (int i = 0; i < daunandong.length; i++) { + System.out.println("==DAUN ANDONG==" + daunandong[i]); + } + } + + //method temu giring + public static void temugiring() { + String temugiring[] = {"\nKANDUNGAN TEMU GIRING:\n1.Tannin\n2.Minyak atsiri\n3.Flavonoida\n4.Piperazin sitrat\n5.Damar\n6.Kurkumin\n7.Protein\n8.Lemak", "MANFAAT:\n1.Mengobati cacingan\n2.Obat sakit perut\n3.Mengobati cacar air\n4.Mengobati kudis", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT JAMU TEMU GIRING:\n1.Air mineral\n2.Temu giring\n3.Madu", "CARA MEMBUAT JAMU TEMU GIRING:\n1.Cuci temu giring hingga bersih\n2.Parut temu ginring hingga halus\n3.Masukan hasil arutan kedalam gelas\n4.Rebus air hingga mendidih\n5.Tuangkan air ke dalam gelas yang berisi hasil parutan temu giring\n6.Saring dan tambahkan madu supaya lebih nikmat\n7.Jamu temu giring siap diminum"}; + for (int i = 0; i < temugiring.length; i++) { + System.out.println("==TEMU GIRING==" + temugiring[i]); + } + } + + //method akar wangi + public static void akarwangi() { + String akarwangi[] = {"\nKANDUNAGN AKAR WANGI:\n1.Senyawa karbonil\n2.Ester\n3.Vetiveron\n4.Seskuiterpen\n5.Seskuiterpen derivatif", "MANFAAT:\n1.Mengatasi bau mulut\n2.Mengobati rematik\n3.Mengobati batu ginjal\n4.Menurunkan demam", "BAHAN-BAHAN YANG DIPERLUKAN UNTUK MEMBUAT SEDUHAN AKAR WANGI:\n1.Akar wangi secukupnya\n2.Air secukupnya\n3.Garam", "CARA MEMBUAT SEDUHAN AKAR WANGI:\n1.Cuci terlebih dahulu akar wangi\n2.Potong-potong akar wangi, rebus dengan air sampai mendidih\n3.Masukan garam secukupnya\n4.Tunggu hingga air mengeluarkan wangi\n5.Tuangkan air di gelas tunggu hingga hangat\n6.Air akar wangi siap untuk diminum"}; + for (int i = 0; i < akarwangi.length; i++) { + System.out.println(ANSI_GREEN + "==AKAR WANGI==" + akarwangi[i]); + } + } + + + String[] datatumbuhan = {"Jahe", "Kunyit", "Daun jabu biji", "Temulawak", "Sambiloto", "Kijibeling", "Kumis kucing", "Pegagan", + "Daun cincau", "Lidah buaya", "Daun beluntas", "Belimbing wuluh", "Brotowali", "Daun jinten", "Kayu manis", "Seledri", "Daun kelor", + "Daun murbei", "Sirih merah", "Daun asam", "Alang-Alang", "Daun tempuyung", "Daun andong", "Temu giring", "Akar wangi"}; + + + public void shellsort(){ + int in,out; + datatumbuhan + } + public static void display(String []a){ + for (int i = 0; i < a.length; i++) { + System.out.println((i+1)+" " + a[i]); + } + } + public void daftar() { + int data; + int pilih; + String ulang2; + try { + do { + String ulang; + BufferedReader a = new BufferedReader(new InputStreamReader(System.in)); + System.out.println("Selamat datang di aplikasi tanaman TOGA"); + System.out.println(ANSI_BLUE + "1.Silahkan pilih daftar tumbuhan\n" + ANSI_RED + "2.Pencaharian berdasarkan penyakit\n"+"3.Sorting berdasarkan abjad"); + System.out.print("Silahkan dipilih: "); + data = Integer.parseInt(a.readLine()); + do { + //kode ketika memilih pilihan 1 + if (data == 1) { +// String[] datatumbuhan = {"Jahe", "Kunyit", "Daun jabu biji", "Temulawak", "Sambiloto", "Kijibeling", "Kumis kucing", "Pegagan", +// "Daun cincau", "Lidah buaya", "Daun beluntas", "Belimbing wuluh", "Brotowali", "Daun jinten", "Kayu manis", "Seledri", "Daun kelor", +// "Daun murbei", "Sirih merah", "Daun asam", "Alang-Alang", "Daun tempuyung", "Daun andong", "Temu giring", "Akar wangi"}; + for (int i = 0; i < datatumbuhan.length; i++) { + System.out.println((i + 1) + ". " + datatumbuhan[i]); + } +// System.out.println("1.Jahe"); +// System.out.println("2.Kunyit"); +// System.out.println("3.Daun jambu biji"); +// System.out.println("4.Temulawak"); +// System.out.println("5.Sambiloto"); +// System.out.println("6.Kijibeling"); +// System.out.println("7.Kumis kucing"); +// System.out.println("8.Pegagan"); +// System.out.println("9.Daun cincau"); +// System.out.println("10.Lidah buaya"); +// System.out.println("11.Daun beluntas"); +// System.out.println("12.Belimbing wuluh"); +// System.out.println("13.Brotowali"); +// System.out.println("14.Daun jinten"); +// System.out.println("15.Kayu manis"); +// System.out.println("16.Seledri"); +// System.out.println("17.Daun kelor"); +// System.out.println("18.Daun murbei"); +// System.out.println("19.Sirih merah"); +// System.out.println("20.Daun asam"); +// System.out.println("21.Alang-alang"); +// System.out.println("22.Daun tempuyung"); +// System.out.println("23.Daun andong"); +// System.out.println("24.Temu giring"); +// System.out.println("25.Akar wangi"); + System.out.print(ANSI_BLUE + "Silahkan pilih daftar tumbuhan diatas:"); + pilih = input.nextInt(); + System.out.println(""); + //kode memilih tanaman herbal menggunakan angka + switch (pilih) { + case 1: + jahe(); + break; + case 2: + kunyit(); + break; + case 3: + daunjambubiji(); + break; + case 4: + temulawak(); + break; + case 5: + sambiloto(); + break; + case 6: + kijibeling(); + break; + case 7: + kumiskucing(); + break; + case 8: + pegagan(); + break; + case 9: + dauncincau(); + break; + case 10: + lidahbuaya(); + break; + case 11: + daunbeluntas(); + break; + case 12: + belimbingwuluh(); + break; + case 13: + brotowali(); + break; + case 14: + daunjinten(); + break; + case 15: + kayumanis(); + break; + case 16: + seledri(); + break; + case 17: + daunkelor(); + break; + case 18: + daunmurbei(); + break; + case 19: + sirihmerah(); + break; + case 20: + daunasam(); + break; + case 21: + alangalang(); + break; + case 22: + dauntempuyung(); + break; + case 23: + daunandong(); + break; + case 24: + temugiring(); + break; + case 25: + akarwangi(); + break; + } + } + //kode ketika memilih pilihan ke-2 + if (data == 2) { + System.out.println("Silahkan masukan keluhan kesehatan yang ingin anda cari"); + String nilai = a.readLine(); + System.out.println(""); + if (nilai.equals("Batuk") || nilai.equals("batuk")) { + kumiskucing(); + System.out.println(""); + System.out.println(""); + belimbingwuluh(); + System.out.println(""); + System.out.println(""); + daunjinten(); + System.out.println(""); + System.out.println(""); + seledri(); + System.out.println(""); + System.out.println(""); + sirihmerah(); + System.out.println(""); + System.out.println(""); + daunasam(); + + } else if (nilai.equals("Malaria") || nilai.equals("malaria")) { + sambiloto(); + System.out.println(""); + System.out.println(""); + daunasam(); + } else if (nilai.equals("Diabetes") || nilai.equals("diabetes")) { + kayumanis(); + System.out.println(""); + System.out.println(""); + daunjambubiji(); + System.out.println(""); + System.out.println(""); + kumiskucing(); + System.out.println(""); + System.out.println(""); + brotowali(); + System.out.println(""); + System.out.println(""); + daunkelor(); + System.out.println(""); + System.out.println(""); + sirihmerah(); + } else if (nilai.equals("Darah Tinggi") || nilai.equals("darah tinggi") || nilai.equals("Hipertensi") || nilai.equals("hipertensi")) { + daunbeluntas(); + System.out.println(""); + System.out.println(""); + seledri(); + System.out.println(""); + System.out.println(""); + dauncincau(); + System.out.println(""); + System.out.println(""); + daunmurbei(); + System.out.println(""); + System.out.println(""); + alangalang(); + } else if (nilai.equals("Asma") || nilai.equals("asma")) { + daunjinten(); + System.out.println(""); + System.out.println(""); + seledri(); + System.out.println(""); + System.out.println(""); + daunasam(); + System.out.println(""); + System.out.println(""); + alangalang(); + } else if (nilai.equals("Alergi") || nilai.equals("alergi")) { + jahe(); + System.out.println(""); + System.out.println(""); + kumiskucing(); + } else if (nilai.equals("Komedo") || nilai.equals("komedo")) { + daunjambubiji(); + } else if (nilai.equals("Gagal ginjal") || nilai.equals("gagal ginjal")) { + kijibeling(); + } else if (nilai.equals("Sariawan") || nilai.equals("sariawan")) { + pegagan(); + System.out.println(""); + System.out.println(""); + belimbingwuluh(); + } else if (nilai.equals("Kembung") || nilai.equals("kembung")) { + daunjambubiji(); + System.out.println(""); + System.out.println(""); + daunjinten(); + } else if (nilai.equals("Panas dalam") || nilai.equals("panas dalam")) { + pegagan(); + System.out.println(""); + System.out.println(""); + alangalang(); + } else if (nilai.equals("Sembelit") || nilai.equals("sembelit")) { + kumiskucing(); + System.out.println(""); + System.out.println(""); + seledri(); + } else if (nilai.equals("Tumor") || nilai.equals("tumor")) { + sirihmerah(); + } else if (nilai.equals("Bronkitis") || nilai.equals("bronkitis")) { + sirihmerah(); + } else if (nilai.equals("Mata merah") || nilai.equals("mata merah")) { + sirihmerah(); + } else if (nilai.equals("Diare") || nilai.equals("diare")) { + kunyit(); + System.out.println(""); + System.out.println(""); + daunjambubiji(); + System.out.println(""); + System.out.println(""); + kijibeling(); + System.out.println(""); + System.out.println(""); + alangalang(); + System.out.println(""); + System.out.println(""); + daunandong(); + } else if (nilai.equals("Hepatitis") || nilai.equals("hepatitis")) { + daunmurbei(); + System.out.println(""); + System.out.println(""); + sambiloto(); + System.out.println(""); + System.out.println(""); + daunasam(); + System.out.println(""); + System.out.println(""); + temulawak(); + System.out.println(""); + System.out.println(""); + alangalang(); + System.out.println(""); + System.out.println(""); + dauntempuyung(); + } else if (nilai.equals("Radang") || nilai.equals("radang")) { + kunyit(); + System.out.println(""); + System.out.println(""); + belimbingwuluh(); + } else if (nilai.equals("Radang sendi") || nilai.equals("radang sendi")) { + temulawak(); + } else if (nilai.equals("Rematik") || nilai.equals("rematik")) { + jahe(); + System.out.println(""); + System.out.println(""); + daunbeluntas(); + System.out.println(""); + System.out.println(""); + brotowali(); + System.out.println(""); + System.out.println(""); + kayumanis(); + System.out.println(""); + System.out.println(""); + akarwangi(); + } else if (nilai.equals("Wasir") || nilai.equals("wasir")) { + lidahbuaya(); + System.out.println(""); + System.out.println(""); + dauntempuyung(); + System.out.println(""); + System.out.println(""); + daunandong(); + } else if (nilai.equals("Anemia") || nilai.equals("anemia")) { + seledri(); + System.out.println(""); + System.out.println(""); + daunkelor(); + } else if (nilai.equals("Kanker") || nilai.equals("kanker")) { + jahe(); + System.out.println(""); + System.out.println(""); + temulawak(); + System.out.println(""); + System.out.println(""); + kijibeling(); + System.out.println(""); + System.out.println(""); + dauncincau(); + System.out.println(""); + System.out.println(""); + belimbingwuluh(); + System.out.println(""); + System.out.println(""); + seledri(); + } else if (nilai.equals("Jantung") || nilai.equals("jantung")) { + kayumanis(); + System.out.println(""); + System.out.println(""); + alangalang(); + } else if (nilai.equals("Stroke") || nilai.equals("stroke")) { + daunjinten(); + } else if (nilai.equals("Demam") || nilai.equals("demam")) { + sambiloto(); + System.out.println(""); + System.out.println(""); + pegagan(); + System.out.println(""); + System.out.println(""); + dauncincau(); + System.out.println(""); + System.out.println(""); + brotowali(); + System.out.println(""); + System.out.println(""); + daunjinten(); + System.out.println(""); + System.out.println(""); + daunkelor(); + System.out.println(""); + System.out.println(""); + alangalang(); + System.out.println(""); + System.out.println(""); + akarwangi(); + } else if (nilai.equals("Keputihan") || nilai.equals("keputihan")) { + daunbeluntas(); + } else if (nilai.equals("TBC") || nilai.equals("tbc")) { + daunbeluntas(); + } else if (nilai.equals("Sakit gigi") || nilai.equals("sakit gigi")) { + sambiloto(); + } else if (nilai.equals("Maag") || nilai.equals("maag")) { + kunyit(); + } else if (nilai.equals("Kencing batu") || nilai.equals("kencing batu")) { + dauntempuyung(); + } else if (nilai.equals("Asam urat") || nilai.equals("asam urat")) { + dauntempuyung(); + } else if (nilai.equals("Radang gusi") || nilai.equals("radang gusi")) { + daunandong(); + } else if (nilai.equals("Cacingan") || nilai.equals("cacingan")) { + daunkelor(); + System.out.println(""); + System.out.println(""); + temugiring(); + } else if (nilai.equals("Sakit perut") || nilai.equals("sakit perut")) { + dauncincau(); + System.out.println(""); + System.out.println(""); + temugiring(); + } else if (nilai.equals("Cacar air") || nilai.equals("cacar air")) { + temugiring(); + } else if (nilai.equals("Bau mulut") || nilai.equals("bau mulut")) { + akarwangi(); + } else if (nilai.equals("Batu ginjal") || nilai.equals("batu ginjal")) { + akarwangi(); + } else { + System.out.println("TIDAK ADA DI DAFTAR PENCAHARIAN"); + } + } + if (data == 3) { + String[] datatum= datatumbuhan; + System.out.println("Sorting berdasarkan abjad"); + Bubblesort(datatum); + + } + System.out.println(""); + //kode pengulangan ke halaman yang tadi + System.out.println("apakah anda ingin kembali lagi?y/n"); + ulang = input.next(); + } while (ulang.equals("y") || ulang.equals("Y")); + //kode pengulangan ke halaman home + System.out.println("apakah anda mau kembali ke home?y/n"); + ulang2 = input.next(); + } while (ulang2.equals("y") || ulang2.equals("Y")); + System.out.println(">>>>>>>>>>>>>>>TERIMA KASIH<<<<<<<<<<<<<<<"); + System.out.println("Semoga sehat selalu"); + System.out.println("Copyright Galuh Muhammad Iman Akbar"); + } catch (Exception e) { + System.out.println("Masukan inputan dengan benar"); + System.out.println(""); + daftar(); + } + } + + public static void main(String[] args) { + Project_UAS2 oke= new Project_UAS2(); + try { + oke.daftar(); + } catch (Exception e) { + System.out.println("salah"); + + } + + } +} diff --git a/pythagorastheorem-new.c b/pythagorastheorem-new.c new file mode 100644 index 00000000..1128ee30 --- /dev/null +++ b/pythagorastheorem-new.c @@ -0,0 +1,24 @@ + +#include +void main(){ +int i,j,a,b,c,d,t; +int num[100]; +printf("Enter The Numbers\n"); +for(i=0;i<=99;i++){ + scanf("%d",&num[i]); + if(num[i]==-1){ + for(j=i;j<=99;j++) + num[j]=0; + break; +}} +t=i-1; +printf("The Numbers Which you want are :-\n"); +for(i=0;i<=t;i++){ +a=((num[i])*(num[i])); +b=((num[i+1])*(num[i+1])); +c=((num[i+2])*(num[i+2])); +d=a+b; +if(d==c){ + printf("%d %d %d\n",num[i],num[i+1],num[i+2]); +}}} + diff --git a/queue/queue.ts b/queue/queue.ts new file mode 100644 index 00000000..b42b6f64 --- /dev/null +++ b/queue/queue.ts @@ -0,0 +1,33 @@ +export class Queue { + + length: number + + constructor(private _array: T[] = []) { + this.length = _array.length + } + + offer(element: T): void { + this.length++ + this._array.push(element) + } + + poll() { + if (!this._isEmpty) { + return this._array.splice(1)[0] + } + throw new Error('Queue is empty'); + } + + peek() { + if (!this._isEmpty) { + return this._array[0] + } + throw new Error('Queue is empty'); + } + + + + private _isEmpty(): boolean { + return this.length == 0 + } +} \ No newline at end of file diff --git a/railcipher.cpp b/railcipher.cpp new file mode 100644 index 00000000..016785f2 --- /dev/null +++ b/railcipher.cpp @@ -0,0 +1,95 @@ +//It is the code of the Rail Fence Cipher where you will enter the string you want to encypt and also the height of the fence +// and it will Encrypt and decrypt both according to the height of the fence. +//The rail fence cipher (also called a zigzag cipher) is a form of transposition cipher. It derives its name from the way in which it is encoded. +//Author: Mayank a.k.a gozmit +#include +using namespace std; + +// function to encrypt the string and return the result +string encrypt(string s,int n) +{ + int k=s.size(); + string result=""; + + char arr[n][k]; // to make the 2D Fence + for(int i=0;i>s; + cout<<"Enter the height of the tree:"; + cin>>n; + d=encrypt(s,n); + cout< +#include + +using namespace std; + +int main() { + random_device rd; + mt19937 engine(rd()); + uniform_int_distribution<> dist(0, 100); // specify your custom range here + cout << "Random Numbers generated using Mersenne Twister:\n"; + cout << dist(engine) << endl; + cout << dist(engine) << endl; + cout << dist(engine) << endl; + cout << dist(engine) << endl; + cout << dist(engine) << endl; + return 0; +} \ No newline at end of file diff --git a/random number/random.java b/random number/random.java new file mode 100644 index 00000000..8035a319 --- /dev/null +++ b/random number/random.java @@ -0,0 +1,9 @@ +// LANGUAGE: Java +// AUTHOR: Arsalan Azmi +// ENV: JVM +// PURPOSE: Generate Random Number between 5 to 500 +import java.util.random + +Random r = new Random(); + +int r = rand.nextInt(500)+5; \ No newline at end of file diff --git a/random number/randomNo_java b/random number/randomNo_java new file mode 100644 index 00000000..55e06f71 --- /dev/null +++ b/random number/randomNo_java @@ -0,0 +1,29 @@ + +// A Java program to demonstrate random number generation +// using java.util.Random; +import java.util.Random; + +public class generateRandom{ + + public static void main(String args[]) + { + // create instance of Random class + Random rand = new Random(); + + // Generate random integers in range 0 to 999 + int rand_int1 = rand.nextInt(1000); + int rand_int2 = rand.nextInt(1000); + + // Print random integers + System.out.println("Random Integers: "+rand_int1); + System.out.println("Random Integers: "+rand_int2); + + // Generate Random doubles + double rand_dub1 = rand.nextDouble(); + double rand_dub2 = rand.nextDouble(); + + // Print random doubles + System.out.println("Random Doubles: "+rand_dub1); + System.out.println("Random Doubles: "+rand_dub2); + } +} diff --git a/random number/randomnumber_java b/random number/randomnumber_java new file mode 100644 index 00000000..55e06f71 --- /dev/null +++ b/random number/randomnumber_java @@ -0,0 +1,29 @@ + +// A Java program to demonstrate random number generation +// using java.util.Random; +import java.util.Random; + +public class generateRandom{ + + public static void main(String args[]) + { + // create instance of Random class + Random rand = new Random(); + + // Generate random integers in range 0 to 999 + int rand_int1 = rand.nextInt(1000); + int rand_int2 = rand.nextInt(1000); + + // Print random integers + System.out.println("Random Integers: "+rand_int1); + System.out.println("Random Integers: "+rand_int2); + + // Generate Random doubles + double rand_dub1 = rand.nextDouble(); + double rand_dub2 = rand.nextDouble(); + + // Print random doubles + System.out.println("Random Doubles: "+rand_dub1); + System.out.println("Random Doubles: "+rand_dub2); + } +} diff --git a/random_integer.py b/random_integer.py new file mode 100644 index 00000000..fa881b1c --- /dev/null +++ b/random_integer.py @@ -0,0 +1,3 @@ +import random +for x in range(10): + print (random.randint(1,101)) \ No newline at end of file diff --git a/recursion/Tower_of_hanoi.c b/recursion/Tower_of_hanoi.c new file mode 100644 index 00000000..aef64e75 --- /dev/null +++ b/recursion/Tower_of_hanoi.c @@ -0,0 +1,18 @@ +#include + +void towerOfHanoi(int n, char from_rod, char to_rod, char aux_rod) +{ + if (n == 1) + { + printf("\n Move disk 1 from rod %c to rod %c", from_rod, to_rod); + return; + } + towerOfHanoi(n-1, from_rod, aux_rod, to_rod); + printf("\n Move disk %d from rod %c to rod %c", n, from_rod, to_rod); + towerOfHanoi(n-1, aux_rod, to_rod, from_rod); +} +int main() +{ + int n = 10; + towerOfHanoi(n, 'A', 'B', 'C'); // Names of rods +} diff --git a/recursion/Tower_of_hanoi.py b/recursion/Tower_of_hanoi.py new file mode 100644 index 00000000..93691296 --- /dev/null +++ b/recursion/Tower_of_hanoi.py @@ -0,0 +1,13 @@ +# Helping Direct function. +def TowerOfHanoi(n , from_rod, to_rod, aux_rod): + if n == 1: + print "Move disk 1 from rod",from_rod,"to rod",to_rod + return + TowerOfHanoi(n-1, from_rod, aux_rod, to_rod) + print "Move disk",n,"from rod",from_rod,"to rod",to_rod + TowerOfHanoi(n-1, aux_rod, to_rod, from_rod) + +# Driver code +n = 5 +TowerOfHanoi(n, 'A', 'B', 'C') +# Name of rods diff --git a/recursion/factorial.cpp b/recursion/factorial.cpp new file mode 100644 index 00000000..831e0c50 --- /dev/null +++ b/recursion/factorial.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; +int fact(int num) +{ + if(num==0) + return 1; + else + return num*fact(num-1); +} +int main() +{ + int num; + cin< +using namespace std; + +long int reversNumber(long int num) +{ + int temp,flag = 0; + long int rNum; + + if(num < 0) + { + num = num * -1; + flag = 1; + } + + while(num>0) + { + temp = num % 10; + rNum = (rNum * 10) + temp; + num = num / 10; + } + + return flag == 1?(rNum*-1):rNum; + +} + + +int main() +{ + long int num = 123456789; + + cout< 2): + print("Error: Invalid number of arguments. Please input one Roman or Arabic numeral.") + sys.exit() + +mmPrint("You have input: ", inputValue) + +containsRoman = False +containsArabic = False +isInvalid = False + +parsedList = list(inputValue) +for character in parsedList: + try: + character = character.upper() + except: + x = 1 + try: + character = int(character) + except: + x = 1 + if character in RomanValueDict: + containsRoman = True + elif isinstance(character, int): + containsArabic = True + else: + isInvalid = True + + +if ((containsRoman and containsArabic) or isInvalid): + print("Error: Input is not a Roman or Arabic numeral.") + sys.exit() + + +if (containsRoman): + mmPrint("Input is processed as a Roman numeral") + RValue = inputValue.upper() + Sum = 0 + for index in range(len(RValue)): + letter = RValue[index] + digitSign = 1 + iFollowingNumerals = (len(RValue) - index) - 1 + if iFollowingNumerals >= 1: #At least one numeral following + if RomanValueDict[letter] < RomanValueDict[RValue[index+1]]: #IV, IX, IC, VX, etc. + if RomanValueDict[letter] in (1, 10, 100): + if RomanValueDict[RValue[index+1]] in ((RomanValueDict[letter] * 5), (RomanValueDict[letter] * 10)): + if (iFollowingNumerals >=2 and RomanValueDict[letter] == RomanValueDict[RValue[index+2]]): #IVI, XCX, etc. + print("Error: Improperly formatted Roman Numeral: misplaced letters.") + sys.exit() + digitSign = -1 #Event of IV, IX, XL, XC, etc. + else: + print("Error: Improperly formatted Roman Numeral: trailing greater number.") + sys.exit() + if iFollowingNumerals >= 2: #At least two numerals following + if RomanValueDict[letter] == RomanValueDict[RValue[index+1]] and RomanValueDict[RValue[index+2]] in ((RomanValueDict[letter] * 5), (RomanValueDict[letter] * 10)): #IIV, XXC, etc. + print("Error: Improperly formatted Roman Numeral: this program uses Subtractive Notation.") + sys.exit() + if iFollowingNumerals >= 3: #At least three numerals following + if RomanValueDict[letter] == RomanValueDict[RValue[index+1]] == RomanValueDict[RValue[index+2]] == RomanValueDict[RValue[index+3]]: #IIII, XXXX, etc. + print("Error: Improperly formatted Roman Numeral: over 3 successive matching numerals.") + sys.exit() + #Input character is verified correct + Sum += (digitSign * RomanValueDict[letter]) + FinalResult = Sum + + +if (containsArabic): + mmPrint("Input is processed as an Arabic numeral") + if int(inputValue) > maxValueArabic: + print("Error: Input exceeds maximum value of ", maxValueArabic) + sys.exit() + for digit in range(len(parsedList)): + DigitResult = "" + column = (len(parsedList) - digit) - 1 + currentTriplet = RomanTripleTuple[column] + digitValue = int(parsedList[digit]) + if digitValue%5 != 4: + for i in range(digitValue%5): + DigitResult += currentTriplet['u'] #I, II, III, X, XX, (...), CCC + if digitValue >= 5: + DigitResult = currentTriplet['q'] + DigitResult #V, VI, VII, (...), DCCC + elif digitValue == 4: + DigitResult += currentTriplet['u'] + currentTriplet['q'] #IV, XL, CD + elif digitValue == 9: + DigitResult += currentTriplet['u'] + currentTriplet['d'] #IX, XC + FinalResult += DigitResult + +print(FinalResult) + + diff --git a/roots of quadratic equation b/roots of quadratic equation index ae025f1e..7dd5e365 100644 --- a/roots of quadratic equation +++ b/roots of quadratic equation @@ -4,7 +4,7 @@ int main() { double a, b, c, discriminant, root1, root2, realPart, imaginaryPart; printf("Enter coefficients a, b and c: "); - scanf("%f %f %f",&a, &b, &c); + scanf("%lf %lf %lf",&a, &b, &c); discriminant = b*b-4*a*c; if (discriminant > 0) { diff --git a/round-robin/round_robin.py b/round-robin/round_robin.py new file mode 100644 index 00000000..1d6aa672 --- /dev/null +++ b/round-robin/round_robin.py @@ -0,0 +1,62 @@ + +if __name__ =='__main__': + + # Python program for implementation of RR Scheduling + + print("Enter Total Process Number: ") + total_p_no = int(input()) + total_time = 0 + total_time_counted = 0 + # proc is process list + proc = [] + wait_time = 0 + turnaround_time = 0 + + for _ in range(total_p_no): + # Getting the input for process + print("Enter process arrival time and burst time") + input_info = list(map(int, input().split(" "))) + arrival, burst, remaining_time = input_info[0], input_info[1], input_info[1] + # processes are appended to the proc list in following format + proc.append([arrival, burst, remaining_time,0]) + # total_time gets incremented with burst time of each process + total_time += burst + + + + print("Enter time quantum") + time_quantum = int(input()) + print(total_time) + + # Keep traversing in round robin manner until the total_time == 0 + while(total_time != 0): + # traverse all the processes + for i in range(len(proc)): + # proc[i][2] here refers to remaining_time for each process i.e "i" + + if(proc[i][2] <= time_quantum and proc[i][2] >= 0): + total_time_counted += proc[i][2] + total_time -= proc[i][2] + # the process has completely ended here thus setting it's remaining time to 0. + proc[i][2] = 0 + + elif(proc[i][2] >0): + # if process has not finished, decrementing it's remaining time by time_quantum + proc[i][2] -= time_quantum + total_time -= time_quantum + total_time_counted += time_quantum + + if(proc[i][2] == 0 and proc[i][3]!=1): + + # if remaining time of process is 0 + # and + # individual waiting time of process has not been calculated i.e flag + wait_time += total_time_counted - proc[i][0] - proc[i][1] + turnaround_time += total_time_counted - proc[i][0] + # flag is set to 1 once wait time is calculated + proc[i][3] = 1 + + + + print("\nAvg Waiting Time is ",(wait_time*1.0)/total_p_no) + print("Avg Turnaround Time is ",(turnaround_time*1.0)/total_p_no,"\n") diff --git a/searching/.DS_Store b/searching/.DS_Store deleted file mode 100644 index 5008ddfc..00000000 Binary files a/searching/.DS_Store and /dev/null differ diff --git a/searching/LinearSearch/lin_search.cpp b/searching/LinearSearch/lin_search.cpp index 4a83c97d..45e9a0ef 100644 --- a/searching/LinearSearch/lin_search.cpp +++ b/searching/LinearSearch/lin_search.cpp @@ -5,6 +5,7 @@ return -1 */ #include using namespace std; + int search(int arr[], int n, int x) { int i; @@ -13,18 +14,19 @@ int search(int arr[], int n, int x) return i; return -1; } + int main() { cout<<"enter size of array "; int n,k; cin>>n; - int * arr= new int [n]; + int * arr = new int [n]; cout<<"enter elements of array "; - for(int i=0;i>arr[i]; cout<<"enter the element to be searched"; cin>>k; - if(search(arr,n,k)==-1) + if(search(arr,n,k) == -1) cout<<"element not found"; else cout<<"element is present at "< + +int main() +{ + int array[100], search, count, num; + + printf("Enter number of elements in array\n"); + scanf("%d", &num); + + printf("Enter %d integer(s)\n", num); + + for (count = 0; count < num; count++) + scanf("%d", &array[count]); + + printf("Enter a number to search\n"); + scanf("%d", &search); + + for (count = 0; count < num; count++) + { + if (array[count] == search) + { + printf("%d is present at location %d.\n", search, count+1); + break; + } + } + if (count == num) + printf("%d isn't present in the array.\n", search); + + return 0; +} \ No newline at end of file diff --git a/searching/linearsearch.cpp b/searching/linearsearch.cpp index 1480b855..5354e1e9 100644 --- a/searching/linearsearch.cpp +++ b/searching/linearsearch.cpp @@ -1,29 +1,43 @@ -#include -#include +#include + using namespace std; + int main() { - int a[20],n,key,pos=-1; + int n, key, pos = -1; + cout<<"Enter the number of elements: "; cin>>n; - system("cls");//To clear the screen + + int a[n]; + cout<<"Enter the Elements"<>a[i]; } - system("cls"); + cout<>key; - for(int i=0;iarr[position_of_max]: + position_of_max = j + temp = arr[i] + arr[i] = arr[position_of_max] + arr[position_of_max] = temp + return arr + +arr = [13,4,12,1,5] +print selection_sort(arr) diff --git a/simple_intrest.cpp b/simple_intrest.cpp index d4f485f2..383f83c5 100644 --- a/simple_intrest.cpp +++ b/simple_intrest.cpp @@ -4,11 +4,11 @@ using namespace std; int main() { int p,r,t,i; - cout<<"Enter Principle : "; + cout<<"Enter Principle : "<<"\n"; cin>>p; - cout<<"Enter Rate : "; + cout<<"Enter Rate : "<<"\n"; cin>>r; - cout<<"Enter Time : "; + cout<<"Enter Time : "<<"\n"; cin>>t; i=(p*r*t)/100; cout<<"Simple interest is : "< +#include +#define Length 6 //Define your array length here + + +//Decreasing Bubble Sort + +int main() +{ + + int array[Length]; + int i; + int j; + int aux; + + printf("Give program the numbers\n"); + + //Feeding our array + for(i=0; i 0; gap /= 2) + { + // Do a gapped insertion sort for this gap size. + // The first gap elements a[0..gap-1] are already + // in gapped order keep adding one more element + // until the entire array is gap sorted + for (int i = gap; i < n; i += 1) + { + // add a[i] to the elements that have been gap + // sorted save a[i] in temp and make a hole at + // position i + int temp = arr[i]; + + // shift earlier gap-sorted elements up until + // the correct location for a[i] is found + int j; + for (j = i; j >= gap && arr[j - gap] > temp; j -= gap) + arr[j] = arr[j - gap]; + + // put temp (the original a[i]) in its correct + // location + arr[j] = temp; + } + } + return 0; + } + + // Driver method + public static void main(String args[]) + { + int arr[] = {12, 34, 54, 2, 3}; + System.out.println("Array before sorting"); + printArray(arr); + + ShellSort ob = new ShellSort(); + ob.sort(arr); + + System.out.println("Array after sorting"); + printArray(arr); + } +} \ No newline at end of file diff --git a/sorting/Tim_Sort.cpp b/sorting/Tim_Sort.cpp new file mode 100644 index 00000000..55e5bf3e --- /dev/null +++ b/sorting/Tim_Sort.cpp @@ -0,0 +1,100 @@ +// TimSort most efficent inplace sorting algorithm divides the array into smaller array +// and then insertion sort is applied and combine using merge sort. +#include +using namespace std; +const int RUN = 32; + +void insertionSort(int arr[], int left, int right) +{ + for (int i = left + 1; i <= right; i++) + { + int temp = arr[i]; + int j = i - 1; + while (arr[j] > temp && j >= left) + { + arr[j+1] = arr[j]; + j--; + } + arr[j+1] = temp; + } +} +void merge(int arr[], int l, int m, int r) +{ + int len1 = m - l + 1, len2 = r - m; + int left[len1], right[len2]; + for (int i = 0; i < len1; i++) + left[i] = arr[l + i]; + for (int i = 0; i < len2; i++) + right[i] = arr[m + 1 + i]; + + int i = 0; + int j = 0; + int k = l; + + while (i < len1 && j < len2) + { + if (left[i] <= right[j]) + { + arr[k] = left[i]; + i++; + } + else + { + arr[k] = right[j]; + j++; + } + k++; + } + while (i < len1) + { + arr[k] = left[i]; + k++; + i++; + } + while (j < len2) + { + arr[k] = right[j]; + k++; + j++; + } +} + +void timSort(int arr[], int n) +{ + for (int i = 0; i < n; i+=RUN) + insertionSort(arr, i, min((i+31), (n-1))); + + for (int size = RUN; size < n; size = 2*size) + { + for (int left = 0; left < n; left += 2*size) + { + int mid = left + size - 1; + int right = min((left + 2*size - 1), (n-1)); + merge(arr, left, mid, right); + } + } +} +void printArray(int arr[], int n) +{ + for (int i = 0; i < n; i++) + printf("%d ", arr[i]); + printf("\n"); +} + +int main() +{ + int n; + cout<<"Enter the size of array ?\n"; + cin>>n; + int a[n]; + for(int i=0;i>a[i]; + } + printf("Given Array is\n"); + printArray(a, n); + timSort(a, n); + printf("After Sorting Array is\n"); + printArray(a, n); + return 0; +} diff --git a/sorting/bubble_sort.rb b/sorting/bubble_sort.rb new file mode 100644 index 00000000..220438ee --- /dev/null +++ b/sorting/bubble_sort.rb @@ -0,0 +1,24 @@ +class BubbleSorter + def call(arr) + for i in 0..arr.count-2 + for j in 0..arr.count-2 + if arr[j] > arr[j+1] + temp = arr[j] + arr[j] = arr[j+1] + arr[j+1] = temp + end + end + end + arr + end +end + +arr1 = [5,4,3,2,1,6] +arr2 = [3,2,5,4,7,8,12,1] +arr3 = [87,12,1234,12,2,34,3,2,1,5,4,8,32,1] + +sorter = BubbleSorter.new + +p sorter.call(arr1) +p sorter.call(arr2) +p sorter.call(arr3) diff --git a/sorting/sort_0_1_2.py b/sorting/sort_0_1_2.py new file mode 100644 index 00000000..cd804dcd --- /dev/null +++ b/sorting/sort_0_1_2.py @@ -0,0 +1,20 @@ +def sort_0_1_2(arr, arr_len): + low = 0 + mid = 0 + high = arr_len - 1 + while mid <= high: + if arr[mid] == 0: + arr[low], arr[mid] = arr[mid], arr[low] + low += 1 + mid += 1 + elif arr[mid] == 1: + mid += 1 + else: + arr[high], arr[mid] = arr[mid], arr[high] + high -= 1 + return arr + + +def test(): + arr = [0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1] + print sort_0_1_2(arr, len(arr)) diff --git a/split_csv_file.py b/split_csv_file.py new file mode 100644 index 00000000..a49a1391 --- /dev/null +++ b/split_csv_file.py @@ -0,0 +1,35 @@ +import os + + +def split(filehandler, delimiter=',', row_limit=5000, + output_name_template='output_%s.csv', output_path='.', keep_headers=True): + import csv + reader = csv.reader(filehandler, delimiter=delimiter) + current_piece = 1 + current_out_path = os.path.join( + output_path, + output_name_template % current_piece + ) + current_out_writer = csv.writer(open(current_out_path, 'w'), delimiter=delimiter) + current_limit = row_limit + if keep_headers: + headers = next(reader) + current_out_writer.writerow(headers) + for i, row in enumerate(reader): + if i + 1 > current_limit: + current_piece += 1 + current_limit = row_limit * current_piece + current_out_path = os.path.join( + output_path, + output_name_template % current_piece + ) + current_out_writer = csv.writer(open(current_out_path, 'w'), delimiter=delimiter) + if keep_headers: + current_out_writer.writerow(headers) + current_out_writer.writerow(row) + + +if __name__ == '__main__': + filepath = "amzn-anon-access-samples-2.0.csv" + split(open(filepath, 'r')) + diff --git a/square.cpp b/square.cpp new file mode 100644 index 00000000..760696ff --- /dev/null +++ b/square.cpp @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +using namespace std; + + +int main() +{ + int a[9],b[8][9]= {{8,1,6,3,5,7,4,9,2},{6,1,8,7,5,3,2,9,4},{4,9,2,3,5,7,8,1,6},{2,9,4,7,5,3,6,1,8},{8,3,4,1,5,9,6,7,2},{4,3,8,9,5,1,2,7,6},{6,7,2,1,5,9,8,3,4},{2,7,6,9,5,1,4,3,8}}; + int min=1000,i,j; + + for(i=0;i<9;i++) + cin>>a[i]; + for(i=0;i<8;i++) + { + int c=0; + for(j=0;j<9;j++) + { + c+=abs(a[j]-b[i][j]); + + } + if(min>c) + min=c; + } + cout< { + + length: number; + + constructor(private _array: T[] = []) { + this.length = _array.length; + } + + peek(): T { + if (!this._isEmpty) { + return this._array[this.length - 1] + } + throw new Error('Stack is empty'); + } + + pop(): T { + if (!this._isEmpty) { + this.length-- + return this._array.pop() + } + throw new Error('Stack is empty'); + } + + push(element: T): void { + this.length++ + this._array.push(element) + } + + private _isEmpty(): boolean { + return this.length == 0 + } + +} \ No newline at end of file diff --git a/strlen.asm b/strlen.asm new file mode 100644 index 00000000..5d606677 --- /dev/null +++ b/strlen.asm @@ -0,0 +1,21 @@ + global asm_strlen:function + + section .text: +asm_strlen: + push rbp + mov rbp, rsp + + mov rax, rdi + + .loop_begin: + mov dl, BYTE [rax] + cmp dl, 0x0 + je short .loop_end + inc rax + jmp short .loop_begin + + .loop_end: + sub rax, rdi + + pop rbp + ret diff --git a/sum_of_taylor_series.c b/sum_of_taylor_series.c new file mode 100644 index 00000000..99673a64 --- /dev/null +++ b/sum_of_taylor_series.c @@ -0,0 +1,31 @@ +#include + +#include + +int main() +{ + printf("\n\n\t\tStudytonight - Best place to learn\n\n\n"); + + int x,i; + int fact = 1,n; + float sum=0; + + printf("\n\nEnter the value of x in the series : "); + scanf("%d",&x); + + printf("\nEnter the number of terms in the series : "); + scanf("%d",&n); + + for(i=1;i 1: + # port = int(split[1]) + host = split[0] + ptcl = ConnectionProtocol(self, data) + coro = loop.create_connection(lambda: ptcl, addr, port) + server = asyncio.ensure_future(coro) + + def parse(self, data): + return data.split()[4] + + def proxy_data_recv(self, data): + self.transport.write(data) + self.transport.close() + +class ConnectionProtocol(asyncio.Protocol): + def __init__(self, proxy, data): + self.proxy = proxy + self.data = data + + def connection_made(self, transport): + self.transport = transport + self.transport.write(self.data) + + def data_received(self, data): + self.proxy.proxy_data_recv(data) + self.transport.close() + +connections = [] +users = [] +loop = asyncio.get_event_loop() +print("{}:{}".format(addr, port)) +coro = loop.create_server(lambda: ProxyProtocol(connections, users, loop), addr, port) +server = loop.run_until_complete(coro) +loop.run_forever() +server.close() +loop.run_until_complete(server.wait_closed()) +loop.close() diff --git a/telephone-validator/validator.go b/telephone-validator/validator.go new file mode 100644 index 00000000..fa0a7683 --- /dev/null +++ b/telephone-validator/validator.go @@ -0,0 +1,27 @@ +package main + +import "strings" + +func main() { + validNumber := "1111111111" + badNumber := "11111111111" + if validateNumber(validNumber) { + fmt.Println(validNumber + " is valid!") + } else { + fmt.Println(validNumber + " is invalid!") + } + if validateNumber(badNumber) { + fmt.Println(badNumber + " is valid!") + } else { + fmt.Println(badNumber + " is invalid!") + } +} + +func validateNumber(number string) bool { + if number != nil && len(number) == 10 { + return true + } else { + return false + } + return false +} diff --git a/telephone-validator/validator.swift b/telephone-validator/validator.swift new file mode 100644 index 00000000..3cb5f914 --- /dev/null +++ b/telephone-validator/validator.swift @@ -0,0 +1,5 @@ +func validatePhoneNumber(value: String) -> Bool { + let phoneRegex = "^\\d{3}-\\d{3}-\\d{4}$" + let phoneTest = NSPredicate(format: "SELF MATCHES %@", phoneRegex) + return phoneTest.evaluate(with: value) +} \ No newline at end of file diff --git a/telephone_number_validator.py b/telephone_number_validator.py new file mode 100644 index 00000000..b5e7b0ea --- /dev/null +++ b/telephone_number_validator.py @@ -0,0 +1,24 @@ +import re + + +class TelephoneNumberValidator: + + def __init__(self, number): + self.number = number + + def isnumber_valid(self): + # 1) Begins with 0 or 91 + # 2) Then contains 7 or 8 or 9. + # 3) Then contains 9 digits + pattern = re.compile("(0/91)?[7-9][0-9]{9}") + return pattern.match(self.number) + + +if __name__ == '__main__': + number = "9876345213" + tnv = TelephoneNumberValidator(number) + + if tnv.isnumber_valid(): + print("Telephone Number is Valid") + else: + print ("Telephone Number is not Valid") diff --git a/trees/binary tree/SpiralPrint.cpp b/trees/binary tree/SpiralPrint.cpp new file mode 100644 index 00000000..f1decabc --- /dev/null +++ b/trees/binary tree/SpiralPrint.cpp @@ -0,0 +1,81 @@ +#include +using namespace std; + +// structure For Node +struct Node +{ + struct Node *left, *right; + int data; +}; + +// Utility function to create a new Node +Node* newNode(int data) +{ + Node *temp = new Node; + temp->data = data; + temp->left = temp->right = NULL; + return temp; +} + +// Calculation of Height of a Tree +int height(Node *root) +{ + if(!root) + return 0; + return max(height(root->left),height(root->right))+1; +} + +// Printing Nodes +void NodesAtKthLevel(Node *root,int level,int l) +{ + + if(!root) + return; + if(level==1) + { + cout<data<<" "; + } + else if(level>1){ + if(l) + { + NodesAtKthLevel(root->left,level-1,l); + NodesAtKthLevel(root->right,level-1,l); + } + else + { + NodesAtKthLevel(root->right,level-1,l); + NodesAtKthLevel(root->left,level-1,l); + } + } + +} + + +void printSpiral(Node *root) +{ + int k=height(root); + bool l=false; + if(!root) + return; + + for(int i=1;i<=k;i++) + {NodesAtKthLevel(root,i,l); + l=!l; + } +} +int main() +{ + // Creation of binary tree + Node * root = newNode(1); + root->left = newNode(2); + root->right = newNode(3); + root->left->left = newNode(4); + root->left->right = newNode(5); + root->right->right = newNode(6); + root->right->right->left = newNode(7); + root->left->right->left = newNode(9); + + printSpiral(root); + return 0; +} + diff --git a/validate_telephone_number.py b/validate_telephone_number.py new file mode 100644 index 00000000..69451f6a --- /dev/null +++ b/validate_telephone_number.py @@ -0,0 +1,10 @@ +while True: + try: + number = int(raw_input("Enter Your Telephone Number: ")) + if len(str(number)) != 10: + print("Wrong Telephon Number. Try Again!") + else: + print("Your Number is Valid :)") + break + except ValueError: + print("Please Use Numeric Numbers!")