검색결과 리스트
백준 프로그래밍에 해당되는 글 53건
- 2023.02.18 백준 3052번 나머지(JAVA, C#)
- 2023.02.16 백준 5597번 과제 안 내신 분(JAVA, C#)
- 2023.02.16 백준 2562번 최댓값(JAVA, C#)
- 2023.02.16 백준 10818번 최소, 최대(JAVA, C#) Arrays.sort();
- 2023.02.15 백준 10871번 X보다 작은 수(JAVA, C#)
- 2023.02.15 백준 10807번 개수 세기(JAVA, C#)
- 2023.02.15 백준 1110번 더하기 사이클(JAVA, C#)
- 2023.02.15 백준 10951번 A + B - 4(JAVA, C#) hasNextInt()
글
백준 3052번 나머지(JAVA, C#)
자바
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int[] student = new int[42];
int answer = 0;
for(int i=1; i<=10; i++)
{
int success = sc.nextInt();
student[success%42] = 1;
}
for(int i=0; i<student.length; i++)
{
if(student[i] == 1)
answer++;
}
System.out.println(answer);
sc.close();
}
}
//////
C#
using System;
namespace Baekjoon {
class Program {
static void Main(string[] args) {
int[] student = new int[42];
int arr = 0;
int answer = 0;
for(int i = 1;i<=10;i++)
{
arr = int.Parse(Console.ReadLine());
student[arr%42] = 1;
}
for(int i = 0;i<42;i++)
{
if(student[i] == 1)
answer++;
}
Console.WriteLine(answer);
}
}
}
'백준 프로그래밍' 카테고리의 다른 글
백준 8958번 OX퀴즈(JAVA, C#) charAt(), array[].length() (0) | 2023.02.18 |
---|---|
백준 1546번 평균(JAVA, C#) BufferedReader (0) | 2023.02.18 |
백준 5597번 과제 안 내신 분(JAVA, C#) (0) | 2023.02.16 |
백준 2562번 최댓값(JAVA, C#) (0) | 2023.02.16 |
백준 10818번 최소, 최대(JAVA, C#) Arrays.sort(); (0) | 2023.02.16 |
글
백준 5597번 과제 안 내신 분(JAVA, C#)
자바
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int[] student = new int[31];
for(int i=1; i<29; i++)
{
int success = sc.nextInt();
student[success] = 1;
}
for(int i=1; i<student.length; i++)
{
if(student[i]!=1)
System.out.println(i);
}
sc.close();
}
}
///////////////////////
C#
using System;
using System.Text;
namespace Baekjoon {
class Program {
static void Main(string[] args) {
int[] student = new int[31];
int arr = 0;
for(int i = 0;i<28;i++)
{
arr = int.Parse(Console.ReadLine());
student[arr] = 1;
}
for(int i = 1;i<31;i++)
{
if(student[i] != 1)
Console.WriteLine(i);
} // 자연수라서 0이 나올 수가 없기 때문에 i를 1~30까지만 해준다.
}
}
}
'백준 프로그래밍' 카테고리의 다른 글
백준 1546번 평균(JAVA, C#) BufferedReader (0) | 2023.02.18 |
---|---|
백준 3052번 나머지(JAVA, C#) (0) | 2023.02.18 |
백준 2562번 최댓값(JAVA, C#) (0) | 2023.02.16 |
백준 10818번 최소, 최대(JAVA, C#) Arrays.sort(); (0) | 2023.02.16 |
백준 10871번 X보다 작은 수(JAVA, C#) (0) | 2023.02.15 |
글
백준 2562번 최댓값(JAVA, C#)
자바
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int arr[] = new int[9];
int max = arr[0]; // 최댓값을 담을 변수
int index = 0; // 최댓값의 위치를 담는 변수
for(int i = 0;i<9;i++)
{
arr[i] = sc.nextInt();
if (max < arr[i])
{
max = arr[i];
index = i+1;
}
}
sc.close();
Arrays.sort(arr);
System.out.println(arr[8] + "\n" + index);
}
}
///////////
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class b_2562 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int arr[] = new int[9];
int max = arr[0]; // 최댓값을 담을 변수
int index = 0; // 최댓값의 위치를 담는 변수
for (int i = 0; i < arr.length; i++)
{
arr[i] = Integer.parseInt(br.readLine());
if (max < arr[i])
{
max = arr[i];
index = i+1;
}
}
System.out.println(max);
System.out.println(index);
}
}
////////////////////////////
C#
using System;
using System.Text;
namespace Baekjoon {
class Program {
static void Main(string[] args) {
int[] arr = new int[9];
int index = 0;
int max = arr[0];
for(int i = 0;i<9;i++)
{
arr[i] = int.Parse(Console.ReadLine());
if(max < arr[i])
{
max = arr[i];
index = i+1;
}
}
Array.Sort(arr);
Console.WriteLine(arr[arr.Length-1] + "\n" + index);
}
}
}
'백준 프로그래밍' 카테고리의 다른 글
백준 3052번 나머지(JAVA, C#) (0) | 2023.02.18 |
---|---|
백준 5597번 과제 안 내신 분(JAVA, C#) (0) | 2023.02.16 |
백준 10818번 최소, 최대(JAVA, C#) Arrays.sort(); (0) | 2023.02.16 |
백준 10871번 X보다 작은 수(JAVA, C#) (0) | 2023.02.15 |
백준 10807번 개수 세기(JAVA, C#) (0) | 2023.02.15 |
글
백준 10818번 최소, 최대(JAVA, C#) Arrays.sort();
자바
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int arr[] = new int[a];
for(int i = 0;i<a;i++)
{
arr[i] = sc.nextInt();
}
sc.close();
Arrays.sort(arr);
System.out.println(arr[0] + " " + arr[a-1]);
}
}
혹은
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine()," ");
int index = 0;
int[] arr = new int[N];
while(st.hasMoreTokens()) {
arr[index] = Integer.parseInt(st.nextToken());
index++;
}
Arrays.sort(arr);
System.out.println(arr[0] + " " + arr[a-1]);
}
}
///////////////////////
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class No_10818 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int N = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine());
int[] arr = new int[N];
for (int i = 0; i < N; i++)
{
arr[i] = Integer.parseInt(st.nextToken());
}
sb.append(Arrays.stream(arr).min().getAsInt()).append(" ").append(Arrays.stream(arr).max().getAsInt();
System.out.println(sb);
}
}
////////////////
C#
using System;
using System.Text;
namespace Baekjoon {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
string[] numbers = Console.ReadLine().Split();
int[] arr = new int[n];
for(int i = 0;i<n;i++)
{
arr[i] = int.Parse(numbers[i]);
}
Array.Sort(arr);
Console.WriteLine(arr[0] + " " + arr[n-1]);
}
}
}
////////////////////
using System;
class Program
{
private static int[] numbers;
private static void Main()
{
int min = int.MaxValue;
int max = int.MinValue;
numbers = new int[int.Parse(Console.ReadLine())];
string[] args = Console.ReadLine().Split(' ');
for(int i = 0; i < numbers.Length; i++)
{
int arg = int.Parse(args[i]);
if (arg < min) min = arg;
if (max < arg) max = arg;
}
Console.Write(min.ToString() + " " + max.ToString());
}
}
'백준 프로그래밍' 카테고리의 다른 글
백준 5597번 과제 안 내신 분(JAVA, C#) (0) | 2023.02.16 |
---|---|
백준 2562번 최댓값(JAVA, C#) (0) | 2023.02.16 |
백준 10871번 X보다 작은 수(JAVA, C#) (0) | 2023.02.15 |
백준 10807번 개수 세기(JAVA, C#) (0) | 2023.02.15 |
백준 1110번 더하기 사이클(JAVA, C#) (0) | 2023.02.15 |
글
백준 10871번 X보다 작은 수(JAVA, C#)
자바
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int arr[] = new int[a];
int x = sc.nextInt();
for(int i = 0;i<a;i++)
{
arr[i] = sc.nextInt();
}
for(int i = 0;i<a;i++)
{
if(arr[i] < x)
{
System.out.println(arr[i]);
}
}
sc.close();
}
}
//////////////////////////////////////
C#
using System;
using static System.Console;
using System.Text;
namespace Baekjoon {
class Program {
static void Main(string[] args) {
string[] s = ReadLine().Split();
int n = int.Parse(s[0]);
int y = int.Parse(s[1]);
string[] numbers = ReadLine().Split();
for(int i =0;i<numbers.Length;i++)
{
if(int.Parse(numbers[i]) < y)
{
Console.WriteLine(numbers[i]);
}
}
}
}
}
///////
using System;
using System.Text;
namespace Baekjoon {
class Program {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split();
int n = int.Parse(s[0]);
int y = int.Parse(s[1]);
string[] numbers = Console.ReadLine().Split();
for(int i =0;i<numbers.Length;i++)
{
if(int.Parse(numbers[i]) < y)
{
Console.WriteLine(numbers[i]);
}
}
}
}
}
'백준 프로그래밍' 카테고리의 다른 글
백준 2562번 최댓값(JAVA, C#) (0) | 2023.02.16 |
---|---|
백준 10818번 최소, 최대(JAVA, C#) Arrays.sort(); (0) | 2023.02.16 |
백준 10807번 개수 세기(JAVA, C#) (0) | 2023.02.15 |
백준 1110번 더하기 사이클(JAVA, C#) (0) | 2023.02.15 |
백준 10951번 A + B - 4(JAVA, C#) hasNextInt() (0) | 2023.02.15 |
글
백준 10807번 개수 세기(JAVA, C#)
자바
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int arr[] = new int[a];
int answer = 0;
for(int i = 0;i<a;i++)
{
arr[i] = sc.nextInt();
}
int v = sc.nextInt();
for(int i = 0;i<a;i++)
{
if(arr[i] == v)
{
answer++;
}
}
System.out.println(answer);
sc.close();
}
}
//////////////////////////////////////////
C#
using System;
namespace Baekjoon {
class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
string [] numbers = Console.ReadLine().Split();
string v = Console.ReadLine();
int result = Array.FindAll(numbers, x => x == v).Length;
Console.WriteLine(result);
}
}
}
'백준 프로그래밍' 카테고리의 다른 글
백준 10818번 최소, 최대(JAVA, C#) Arrays.sort(); (0) | 2023.02.16 |
---|---|
백준 10871번 X보다 작은 수(JAVA, C#) (0) | 2023.02.15 |
백준 1110번 더하기 사이클(JAVA, C#) (0) | 2023.02.15 |
백준 10951번 A + B - 4(JAVA, C#) hasNextInt() (0) | 2023.02.15 |
백준 10952번 A+B - 5(JAVA, C#) while문 (0) | 2023.02.15 |
글
백준 1110번 더하기 사이클(JAVA, C#)
자바
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = -1;
int c = a;
int answer = 0;
while(a != b)
{
b = c;
if(a < 10)
{
a = 10 * a + a;
answer++;
}
else
{
a = (a % 10) * 10 + (a/10 + a%10)%10;
answer++;
}
}
System.out.println(answer);
sc.close();
}
}
///////////////////////////
C#
using System;
namespace Baekjoon {
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
int a = int.Parse(s);
int b = -1;
int c = a;
int answer = 0;
while(a != b)
{
b = c;
if(a < 10)
{
a = 10 * a + a;
answer++;
}
else
{
a = (a % 10) * 10 + (a/10 + a%10)%10;
answer++;
}
}
Console.WriteLine(answer);
}
}
}
'백준 프로그래밍' 카테고리의 다른 글
백준 10871번 X보다 작은 수(JAVA, C#) (0) | 2023.02.15 |
---|---|
백준 10807번 개수 세기(JAVA, C#) (0) | 2023.02.15 |
백준 10951번 A + B - 4(JAVA, C#) hasNextInt() (0) | 2023.02.15 |
백준 10952번 A+B - 5(JAVA, C#) while문 (0) | 2023.02.15 |
백준 2439번 별 찍기 - 2(JAVA, C#) (0) | 2023.02.15 |
글
백준 10951번 A + B - 4(JAVA, C#) hasNextInt()
자바
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
while(sc.hasNextInt())
{
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a+b);
}
sc.close();
}
}
[백준] 10951번 : A+B - 4 - JAVA [자바]
https://www.acmicpc.net/problem/10951 10951번: A+B - 4 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net 문제 간단한 문제지만 의외로 종료시점을 몰라 틀리는 경우들이 많
st-lab.tistory.com
참고해야겠다.
/////////////////////////////
C#
using System;
namespace Baekjoon {
class Program {
static void Main(string[] args) {
while(true)
{
string c = Console.ReadLine();
if(c == null)
{
break;
}
string[] ss = c.Split();
int a = int.Parse(ss[0]);
int b = int.Parse(ss[1]);
Console.WriteLine(a+b);
}
}
}
}
/// EOF(End Of File)를 이용하는 거란다.
'백준 프로그래밍' 카테고리의 다른 글
백준 10807번 개수 세기(JAVA, C#) (0) | 2023.02.15 |
---|---|
백준 1110번 더하기 사이클(JAVA, C#) (0) | 2023.02.15 |
백준 10952번 A+B - 5(JAVA, C#) while문 (0) | 2023.02.15 |
백준 2439번 별 찍기 - 2(JAVA, C#) (0) | 2023.02.15 |
백준 별 찍기 - 1(JAVA, C#) (0) | 2023.02.14 |