본문 바로가기
Baekjoon/단계별로 풀어보기

[단계01] 입출력과 사칙연산 (11문제)

by 해적거북 2020. 12. 16.
728x90

www.acmicpc.net/step/1

 

● [문제번호 백준 2557] Hello World

#include <stdio.h>

int main(void)
{
    printf("Hello World!");
    return 0;
}

 

● [문제번호 백준 10718] We love kriii

#include <stdio.h>

int main(void)
{
    printf("강한친구 대한육군\n");
    printf("강한친구 대한육군\n");
    return 0;
}

 

● [문제번호 백준 10171] 고양이

#include <stdio.h>

int main(void)
{
    printf("\\    /\\\n");
    printf(" )  ( \')\n");
    printf("(  /  )\n");
    printf(" \\(__)|\n");
    return 0;
}

 

● [문제번호 10172] 개

#include <stdio.h>

int main(void)
{
    printf("|\\_/|\n");
    printf("|q p|   /}\n");
    printf("( 0 )\"\"\"\\\n");
    printf("|\"^\"`    |\n");
    printf("||_/=\\\\__|\n");
    return 0;
}

 

● [문제번호 1000] A+B

#include <stdio.h>

int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d", a + b);
    return 0;
}

 

● [문제번호 1001] A-B

#include <stdio.h>
int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d",a - b);
    return 0;
}

 

● [문제번호 10998] AxB

#include <stdio.h>

int main(void)
{
    int a,b;
    scanf("%d %d", &a, &b);
    printf("%d",a*b);
    return 0;
}

 

● [문제번호 1008] A/B

#include <stdio.h>

int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%.9f", (double)a / b);
    return 0;
}

 

● [문제번호 10869] 사칙연산

#include <stdio.h>

int main(void)
{
    int a,b;
    scanf("%d %d", &a, &b);
    printf("%d\n",a+b);
    printf("%d\n",a-b);
    printf("%d\n",a*b);
    printf("%d\n",a/b);
    printf("%d\n",a%b);
    return 0;
}

 

● [문제번호 10430] 나머지

#include <stdio.h>

int main(void)
{
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    printf("%d\n",(a+b)%c);
    printf("%d\n",((a%c) + (b%c))%c);
    printf("%d\n",(a*b) % c);
    printf("%d\n",((a%c)*(b%c))%c);
    return 0;
}

 

● [문제번호 2558] 곱셈

#include <stdio.h>

int main(void)
{
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    
    int temp = b;
    printf("%d\n", a * (temp % 10));
    temp /= 10;
    printf("%d\n", a * (temp % 10));
    temp /= 10;
    printf("%d\n", a * (temp % 10));
    
    printf("%d", a * b);
    return 0;
}

// 아직 while문을 사용하면 틀리는 것으로 간주하는 거라 짐작

 

 

\a 경고음 소리 발생
\n 개행 (줄바꿈)
\t 탭 (탭크기만큼 띄우기)
\\ 역슬래쉬 (\)
\' 작은 따옴표 (')
\" 큰 따옴표 (")

 

728x90

'Baekjoon > 단계별로 풀어보기' 카테고리의 다른 글

[단계08] 기본 수학1 (9문제)  (0) 2020.12.20
[단계07] 문자열 (10문제)  (0) 2020.12.20
[단계06] 함수 (3문제)  (0) 2020.12.18
[단계05] 1차원 배열 (7문제)  (0) 2020.12.17
[단계04] while문 (3문제)  (0) 2020.12.17
[단계03] for문 (11문제)  (0) 2020.12.17
[단계02] if문 (5문제)  (0) 2020.12.16

댓글