Code Monkey home page Code Monkey logo

khim ki khim's Projects

greatest icon greatest

import java.util.*; public class Greatest { public static void main(String[]args){ Scanner in = new Scanner(System.in); int input1 = in.nextInt(); /// 7.รับ input เข้ามาสองตัว คือ input1 เเละ input2 int input2 = in.nextInt(); Greatest gr =new Greatest();/// 8.สร้าง object gr gr.printGcd(input1, input2); //9.เรียกใช้เมธอด printGrd เพื่อเเสดงผลออกมา // System.out.println(gr.re(input1,input2)); } public void printGcd(int input1,int input2){ /// 4.สร้างเมธอดเพื่อรับค่ามาสองค่า เพื่อส่งไปแแสดงผลใน main int greatest=0; if(input1>0 && input2>0){ ///// 5.เช็คว่า input1 เเละ input2 ที่รับเข้ามามากกว่า 0 หรือไม่ /* while(input2>0){ greatest=input1%input2; input1=input2; input2=greatest; }*/ System.out.println("greatest common divisor "+reGcd(input1,input2));//// ถ้ามากกว่าก็จะเเสดงค่า ห.ร.ม ออกมาโดยไปเรียกใช้ฟังก์ชัน reGcd }else{ System.err.println("Please check input > 0"); //// 6.ถ้าน้อยกว่า 0 ทำการเเสดงผล Error ว่า lease check input > 0 } } public int reGcd(int input1,int input2) { ///// 1.สร้างฟังก์ชันรีเคอซีฟ ชื่อ re ที่รับค่า input1,input2 เข้ามา if(input2>0){ ///// 2.ทำการสลับตำเเหน่งให้ตำเเหน่งที่ input1=input2 และทำการ นำ input1%input2 return reGcd(input2,input1%input2); ///// จนกว่า ค่า input2 จะเท่ากับ 0 ก็จะได้คำตอบสุดท้ายคือ (input2,0)=input2 } else{ return input1; //// 3.ถ้ามันไม่มากกว่า 0 ก็ให้รีเทรินอะไรออกมาก็ได้ เพราะถ้าเข้าเงื่อนไขนี้ /////จะไปเช็คเงื่อนไขใน method printGcd อีกครั้งหนึ่งว่าตัวเลขที่รับเข้ามากมาก 0 หรือไม่ } } }

speechemo icon speechemo

Emotion context recognition from acoustic feature of speech

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.