2월14일 몫과 나머지

59 views
Skip to first unread message

cybe...@gmail.com

unread,
Feb 13, 2013, 8:48:37 PM2/13/13
to kor...@googlegroups.com
프로그램 명: q_r
제한시간: 1 초
두 자연수를 입력으로 받아 첫 번째 수를 두 번째 수로 나눈 몫과 나머지를 구하는 프로그램을 작성하세요.

입력

두 자연수가 입력으로 주어진다. 두 수는 10000 이하의 자연수이다.

출력

몫 과 나머지를 출력한다.

입출력 예

입력

8 5

출력

1 3

ksk1...@naver.com

unread,
Feb 13, 2013, 9:06:46 PM2/13/13
to kor...@googlegroups.com
import java.util.Scanner;

public class q_r {

public static void main(String[] args) {
int q, r;
Scanner sc = new Scanner(System.in);
System.out.print("입력 : ");
q = sc.nextInt();
r = sc.nextInt();
System.out.print("출력 : ");
System.out.print(q/r + "  " + q%r);
}
}


선해

unread,
Feb 13, 2013, 9:07:05 PM2/13/13
to KorUsn
import java.util.Scanner;

public class Test1 {
public static void main(String[] args){
int num1, num2;

Scanner sc = new Scanner(System.in);

System.out.println("1000이하의 자연수를 두 개 입력하시오.");
num1 = sc.nextInt();
num2 = sc.nextInt();

if((0<num1 && num1<=1000) && (0<num2 && num2<=1000))
System.out.println("몫은 " + num1/num2 + "이고, 나머지는 " + num1%num2 + "입니
다.");
else
System.out.println("1000이하의 자연수만 입력하시오.");
}
}

cybe...@gmail.com

unread,
Feb 13, 2013, 9:07:56 PM2/13/13
to kor...@googlegroups.com
public static void main(String[] args){
int a, b;
Scanner sc = new Scanner(System.in);
while(true){
System.out.println("입력");
a = sc.nextInt();
b = sc.nextInt();
if(a > 10000 || b > 10000)System.out.println("10000이하의 자연수만 입력해주세요");
else {
sc.close();
break;
}
}
System.out.println((a/b) + "\t" + (a%b));
}
Message has been deleted
Message has been deleted

BAE, JUNGWON

unread,
Feb 13, 2013, 9:28:23 PM2/13/13
to kor...@googlegroups.com

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
int a, b, result1, result2;
Scanner sc = new Scanner(System.in);
a = sc.nextInt();
b = sc.nextInt();
result1 = a/b;
result2 = a%b;
System.out.println(result1 + " " + result2);
}
}



Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

kimmo...@gmail.com

unread,
Feb 13, 2013, 9:39:21 PM2/13/13
to kor...@googlegroups.com
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
int f, s;

Scanner sc = new Scanner(System.in);

f = sc.nextInt();
s = sc.nextInt();
System.out.print((f / s) + " " + (f % s));

}

}


경과시간별 순위:
전체: 3987/4116
Java :92/224

코드size 순위:
전체:3934/4116
Java:97/224

kbs...@gmail.com

unread,
Feb 13, 2013, 9:40:41 PM2/13/13
to kor...@googlegroups.com
import java.util.Scanner;


public class Main {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

int a, b;
int c, d;

Scanner sc = new Scanner(System.in);

a = sc.nextInt();
b = sc.nextInt();
c = a / b;
d = a % b;

if(a<=10000){
if(b<=10000){
System.out.print(c + " "); 
System.out.print(d);
}
}
}
}

zros...@naver.com

unread,
Feb 13, 2013, 9:47:37 PM2/13/13
to kor...@googlegroups.com
import java.util.Scanner;


public class Main {

public static void main(String[] args) {
int a,b;
int c,result;
Scanner  sc= new Scanner(System.in);
for(a=0; a<10000; a++){
a = sc.nextInt();
for(b=0; b<10000; b++){
b = sc.nextInt();
result = a / b;
c = a % b;
System.out.print(result + " ");
System.out.print(c);

}

}
}
}

Gee-Eun KIM

unread,
Feb 13, 2013, 10:05:15 PM2/13/13
to kor...@googlegroups.com


import java.util.Scanner;


public class Test1 {

public static void main(String[] args) {
int i=0,j=0;
Scanner s=new Scanner(System.in);
i=s.nextInt();
j=s.nextInt();
System.out.printf("%d %d",i/j,i%j);

}

}
Message has been deleted

김민찬

unread,
Feb 13, 2013, 10:10:48 PM2/13/13
to kor...@googlegroups.com
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int mok = sc.nextInt();
int namuji = sc.nextInt();
System.out.println((mok/namuji)+" "+(mok%namuji));
}
}

경과시간별 순위:
전체: 3931/4113
Java :33/221
코드size 순위:
전체:3927/4113
Java:91/221
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

정영재

unread,
Feb 13, 2013, 10:14:25 PM2/13/13
to kor...@googlegroups.com
import java.util.Scanner;

public class q_r {

public static void main(String[] args) {

int q, r;
Scanner sc = new Scanner(System.in);
q = sc.nextInt();
r = sc.nextInt();
System.out.print(q / r + " " + q % r);

}

}
Message has been deleted

qgqg...@gmail.com

unread,
Feb 13, 2013, 10:38:07 PM2/13/13
to kor...@googlegroups.com
import java.util.Scanner;

public class q_r {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int first,second;
       
        first = sc.nextInt();
        second = sc.nextInt();
       
        System.out.println((first/second)+" "+(first%second));
    }
}

경과시간별 순위:

    전체: 3924/4121
    Java :26/229

코드size 순위:

    전체:4066/4121
    Java:196/229

Suyeon Kim

unread,
Feb 13, 2013, 10:44:20 PM2/13/13
to kor...@googlegroups.com
import java.util.Scanner;

public class Test1 {

public static void main(String[] args) {

int a,b;

Scanner sc=new Scanner(System.in);
a=sc.nextInt();
b=sc.nextInt();

System.out.print(a/b+" "+a%b);


}

}

Message has been deleted

SooYeon park

unread,
Feb 13, 2013, 10:57:05 PM2/13/13
to kor...@googlegroups.com

import java.util.Scanner;
 
 
public class Main{
 
 public static void main(String[] args) {
 
  int a,b;
   
 
  Scanner sc= new Scanner(System.in);
 
   
  a=sc.nextInt();
  b=sc.nextInt();
 
  System.out.println(a/b+" "+a%b);
 
 }
}
Message has been deleted

SangSoo Kim

unread,
Feb 14, 2013, 12:05:07 AM2/14/13
to kor...@googlegroups.com
import java.util.Scanner;


public class q_r {

public static void main(String[] args) {
int a,b;
Scanner sc = new Scanner(System.in);
System.out.print("첫번째 수 :");
a=sc.nextInt();
System.out.print("두번째 수 :");
b=sc.nextInt();
System.out.print(a/b+" "+a%b);
}
}

이정욱

unread,
Feb 14, 2013, 12:05:47 AM2/14/13
to kor...@googlegroups.com
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
 
        int Q, R;
         
        Scanner sc = new Scanner(System.in);
         
        Q = sc.nextInt();
         
        R = sc.nextInt();
 
        if( Q >10000 && R > 10000){
            return;
        }
 
        System.out.print(Q/R + " ");
        System.out.print(Q%R);
    }
}
Reply all
Reply to author
Forward
0 new messages