chall.py

#!/usr/bin/python3
from Crypto.Util.number import getPrime, long_to_bytes, inverse
flag = open('flag.txt', 'r').read().strip().encode()

class RSA:
    def __init__(self):
        self.p = getPrime(512)
        self.q = getPrime(512)
        self.e = 3
        self.n = self.p * self.q
        self.d = inverse(self.e, (self.p-1)*(self.q-1))
    def encrypt(self, data: bytes) -> bytes:
        pt = int(data.hex(), 16)
        ct = pow(pt, self.e, self.n)
        return long_to_bytes(ct)
    def decrypt(self, data: bytes) -> bytes:
        ct = int(data.hex(), 16)
        pt = pow(ct, self.d, self.n)
        return long_to_bytes(pt)

def main():
    crypto = RSA()
    print ('Flag:', crypto.encrypt(flag).hex())

if __name__ == '__main__':
    main()

 

output.txt

Flag: 05c61636499a82088bf4388203a93e67bf046f8c49f62857681ec9aaaa40b4772933e0abc83e938c84ff8e67e5ad85bd6eca167585b0cc03eb1333b1b1462d9d7c25f44e53bcb568f0f05219c0147f7dc3cbad45dec2f34f03bcadcbba866dd0c566035c8122d68255ada7d18954ad604965

 

주어진 두 코드를 보면 ct와 e가 주어진 RSA 문제라는 것을 알 수 있다

n 또한 주어지지 않았기 때문에 ct와 매우 작은 e를 사용하여 낮은지수 공격을 수행하면 될 것 같다

 

sol.py

from gmpy2 import *
from Crypto.Util.number import long_to_bytes

c = int('05c61636499a82088bf4388203a93e67bf046f8c49f62857681ec9aaaa40b4772933e0abc83e938c84ff8e67e5ad85bd6eca167585b0cc03eb1333b1b1462d9d7c25f44e53bcb568f0f05219c0147f7dc3cbad45dec2f34f03bcadcbba866dd0c566035c8122d68255ada7d18954ad604965', 16)
e = 3
 
with local_context() as ctx:
    ctx.precision=3000
    m=iroot(c,e)[0]
 
    print(long_to_bytes(m))

 

'wargame > hack the box' 카테고리의 다른 글

HTB RSAisEasy writeup  (0) 2023.03.30
HTB xorxorxor writeup  (0) 2023.03.30
HTB BabyEncryption writeup  (0) 2022.10.23

chall.py

#!/usr/bin/env python3
from Crypto.Util.number import bytes_to_long, getPrime
from secrets import flag1, flag2
from os import urandom

flag1 = bytes_to_long(flag1)
flag2 = bytes_to_long(flag2)

p, q, z = [getPrime(512) for i in range(3)]

e = 0x10001

n1 = p * q
n2 = q * z

c1 = pow(flag1, e, n1)
c2 = pow(flag2, e, n2)  

E = bytes_to_long(urandom(69))

print(f'n1: {n1}')
print(f'c1: {c1}')
print(f'c2: {c2}')
print(f'(n1 * E) + n2: {n1 * E + n2}')

 

output.txt

n1: 101302608234750530215072272904674037076286246679691423280860345380727387460347553585319149306846617895151397345134725469568034944362725840889803514170441153452816738520513986621545456486260186057658467757935510362350710672577390455772286945685838373154626020209228183673388592030449624410459900543470481715269
c1: 92506893588979548794790672542461288412902813248116064711808481112865246689691740816363092933206841082369015763989265012104504500670878633324061404374817814507356553697459987468562146726510492528932139036063681327547916073034377647100888763559498314765496171327071015998871821569774481702484239056959316014064
c2: 46096854429474193473315622000700040188659289972305530955007054362815555622172000229584906225161285873027049199121215251038480738839915061587734141659589689176363962259066462128434796823277974789556411556028716349578708536050061871052948425521408788256153194537438422533790942307426802114531079426322801866673
(n1 * E) + n2: 601613204734044874510382122719388369424704454445440856955212747733856646787417730534645761871794607755794569926160226856377491672497901427125762773794612714954548970049734347216746397532291215057264241745928752782099454036635249993278807842576939476615587990343335792606509594080976599605315657632227121700808996847129758656266941422227113386647519604149159248887809688029519252391934671647670787874483702292498358573950359909165677642135389614863992438265717898239252246163

 

주어진 코드와 값을 보면 n1을 이용해서 p와 q를 구해볼 수 있다

factordb에 n1을 돌려보면 다음과 같이 p, q가 나온다

(이때 소수 두개가 나오는데 이 중에서 뭐가 p이고 q인지 알 수 없음 -> flag1을 구할 때는 p,q가 바뀌어도 딱히 상관없음)

p = 12040644312371555810530782070969893153760288255333349208608058511112776958879208815174991008199408527954332776642365069284747758115478414463195873149420483
q = 8413387656561188778435613942028835678781206299389177514340760123063579360223360470566083306606450007991287094526418200038784207648097820069671213638771543

이렇게 p, q값을 구했으니 flag1은 구할 수 있지만 n2를 아직 모르기 때문에 flag2는 구할 수 없다

output.txt의 마지막 값인 (n1 * E) + n2를 이용해서 n2를 구해볼 것인데 n1*E+n2에서 n2를 구하려면 (n1*E+n2)%n1 을 하면된다

n1_E_n2 = 601613204734044874510382122719388369424704454445440856955212747733856646787417730534645761871794607755794569926160226856377491672497901427125762773794612714954548970049734347216746397532291215057264241745928752782099454036635249993278807842576939476615587990343335792606509594080976599605315657632227121700808996847129758656266941422227113386647519604149159248887809688029519252391934671647670787874483702292498358573950359909165677642135389614863992438265717898239252246163
n1 = 101302608234750530215072272904674037076286246679691423280860345380727387460347553585319149306846617895151397345134725469568034944362725840889803514170441153452816738520513986621545456486260186057658467757935510362350710672577390455772286945685838373154626020209228183673388592030449624410459900543470481715269

n2 = n1_E_n2%n1
n2 = 100136903041423020991425823526737746365573197640035952973693624809721624428963253203282593974533722584391447008912397042291986993273828302711324440847902763039627790146764630023926517236880457533976468679976683705170312329736955922713306570804595070537102421450884645497775455984735279182873866159334387494837

그리고 이제 z의 값도 구할 수 있다

(처음 문제를 풀 때는 p, q의 값을 바꿔서 써서 n2 = n1_E_n2 % n1의 값과 n2//q로 구한 z의 값을 이용한 n2 = q*z의 값이 달랐었다)

z값은 n2//q를 이용해서 구한다

 

그럼 필요한 값은 모두 구했기 때문에 flag1과 flag2를 구해서 전체 플래그를 구할 수 있다

 

sol.py

from Crypto.Util.number import inverse, long_to_bytes

n1 = 101302608234750530215072272904674037076286246679691423280860345380727387460347553585319149306846617895151397345134725469568034944362725840889803514170441153452816738520513986621545456486260186057658467757935510362350710672577390455772286945685838373154626020209228183673388592030449624410459900543470481715269
c1 = 92506893588979548794790672542461288412902813248116064711808481112865246689691740816363092933206841082369015763989265012104504500670878633324061404374817814507356553697459987468562146726510492528932139036063681327547916073034377647100888763559498314765496171327071015998871821569774481702484239056959316014064
c2 = 46096854429474193473315622000700040188659289972305530955007054362815555622172000229584906225161285873027049199121215251038480738839915061587734141659589689176363962259066462128434796823277974789556411556028716349578708536050061871052948425521408788256153194537438422533790942307426802114531079426322801866673
n1_e_n2 = 601613204734044874510382122719388369424704454445440856955212747733856646787417730534645761871794607755794569926160226856377491672497901427125762773794612714954548970049734347216746397532291215057264241745928752782099454036635249993278807842576939476615587990343335792606509594080976599605315657632227121700808996847129758656266941422227113386647519604149159248887809688029519252391934671647670787874483702292498358573950359909165677642135389614863992438265717898239252246163
e = 0x10001

p = 12040644312371555810530782070969893153760288255333349208608058511112776958879208815174991008199408527954332776642365069284747758115478414463195873149420483
q = 8413387656561188778435613942028835678781206299389177514340760123063579360223360470566083306606450007991287094526418200038784207648097820069671213638771543

n2 = n1_e_n2%n1
z = n2//q

phi1 = (p-1) * (q-1)
d1 = inverse(e, phi1)

phi2 = (q-1) * (z-1)
d2 = inverse(e, phi2)

flag1 = pow(c1, d1, n1)
flag2 = pow(c2, d2, n2)

print(long_to_bytes(flag1) + long_to_bytes(flag2))

'wargame > hack the box' 카테고리의 다른 글

HTB Lost Modulus writeup  (0) 2023.03.30
HTB xorxorxor writeup  (0) 2023.03.30
HTB BabyEncryption writeup  (0) 2022.10.23

chall.py

#!/usr/bin/python3
import os
flag = open('flag.txt', 'r').read().strip().encode()

class XOR:
    def __init__(self):
        self.key = os.urandom(4)
    def encrypt(self, data: bytes) -> bytes:
        xored = b''
        for i in range(len(data)):
            xored += bytes([data[i] ^ self.key[i % len(self.key)]])
        return xored
    def decrypt(self, data: bytes) -> bytes:
        return self.encrypt(data)

def main():
    global flag
    crypto = XOR()
    print ('Flag:', crypto.encrypt(flag).hex())

if __name__ == '__main__':
    main()

 

output.txt

Flag: 134af6e1297bc4a96f6a87fe046684e8047084ee046d84c5282dd7ef292dc9

 

밑의 chall.py 코드를 살펴보면

xored += bytes([data[i] ^ self.key[i % len(self.key)]])

len(self.key)는 os.urandom(4)로 작성했기 때문에 4로 항상 동일하다

따라서 self.key[i % len(self.key)]] 는 i가 4보다 작으면 i값 그대로 리턴해주고 4보다 크면 i-4를 리턴해준다

 

이때 self.key[]는 self.key[0], self.key[1], self.key[2], self.key[3] 이렇게 4개만 있다

-> 그래서 플래그 길이만큼 10진수 4개가 반복해서 플래그 인덱스 i와 xor되어서 이를 바이트로 차례대로 저장한다

 

그리고 이를 16진수로 바꾼게 제공받은 output.txt이다

 

플래그 중 일부분인 HTB{ 라는 플래그 형식을 알고있고 4글자라는 것을 이용해 self.key를 찾아낼 수 있다

output으로 제공받은 16진수에서 2글자 당 평문 글자 하나를 암호화한다

이를 이용해서 키를 구하는 코드를 작성해보면 다음과 같다

a = ['H', 'T', 'B', '{']
b = ['13', '4a', 'f6', 'e1']

key = []
for i in range(4):
    a[i] = hex(ord(a[i]))[2:]
    key.append(int(hex(int(a[i],16)^int(b[i], 16))[2:], 16))

print(key)

그럼 키는 [91, 30, 180, 154] 라는 것을 알 수 있다

 

이제 이 키를 이용해서 제공받은 16진수 플래그를 2글자씩 끊어서 xor해주면 평문인 플래그가 나올 것이다

 

sol.py

#a = ['H', 'T', 'B', '{']
#b = ['13', '4a', 'f6', 'e1']
#
#key = []
#for i in range(4):
#    a[i] = hex(ord(a[i]))[2:]
#    key.append(int(hex(int(a[i],16)^int(b[i], 16))[2:], 16))
#
#print(key)

key = [91, 30, 180, 154]

flag = '134af6e1297bc4a96f6a87fe046684e8047084ee046d84c5282dd7ef292dc9'

arr = []

for i in range(0, len(flag), 2):
    arr.append(int(flag[i] + flag[i+1], 16))

msg = b""
for i in range(len(arr)):
    msg += bytes([arr[i] ^ key[i % 4]])

print(msg)

 

'wargame > hack the box' 카테고리의 다른 글

HTB Lost Modulus writeup  (0) 2023.03.30
HTB RSAisEasy writeup  (0) 2023.03.30
HTB BabyEncryption writeup  (0) 2022.10.23

백준 문제집 리스트 중 automata님의 Python 배우기 (1~50) 문제집의 풀이이다 (간단한 문제들은 설명이 없을 수 있음..)

https://www.acmicpc.net/workbook/view/459

 

문제집: Python 배우기 (1~50) (automata)

 

www.acmicpc.net

 

⭐️ 전에 푼거 아직 옮기는중..

 

2557 - Hello World

print('Hello World!')

 

1000 - A+B

a, b = map(int, input().split())

if 0 < a and b < 10:
    print(a + b)

 

10998 - A×B

a, b = map(int, input().split())

if 0 < a and b < 10:
    print(a*b)

 

1001 - A-B

a, b = map(int, input().split())

if 0 < a and b < 10:
    print(a - b)

 

1008 - A/B

a, b = map(int, input().split())

if 0 < a and b < 10:
    print(a / b)

 

10869 - 사칙연산

a, b = map(int, input().split())

if 1 <= a and b <= 10000:
    print(a + b)
    print(a - b)
    print(a * b)
    print(a // b)
    print(a % b)

 

10430 - 나머지

a, b, c = map(int, input().split())

if 2<=a<=100000 and 2<=b<=100000 and 2<=c<=100000:
    print((a+b)%c)
    print(((a%c)+(b%c))%c)
    print((a*b)%c)
    print(((a%c)*(b%c))%c)

 

2558 - A+B - 2

a = int(input())
b = int(input())
print(a + b)

 

2588 - 곱셈

fir = int(input())
sec = input()

print(fir * int(sec[2]))
print(fir * int(sec[1]))
print(fir * int(sec[0]))
print(fir * int(sec))

 

3046 - R2

R1, S = map(int, input().split())

R2 = S*2 - R1
print(R2)

 

2163 - 초콜릿 자르기

n, m = map(int, input().split())
choco = n*m
print(choco//1-1)

 

11021 - A+B - 7

t = int(input())

for i in range(t):
    a, b = map(int, input().split())
    if 0<a and b<10:
        print('Case #{}: {}' .format(i+1, a+b))

 

11022 - A+B - 8

t = int(input())

for i in range(t):
    a, b = map(int, input().split())
    if 0<a and b<10:
        print('Case #{}: {} + {} = {}'.format(i+1, a, b, a+b))

 

10699 - 오늘 날짜

print("2023-02-22")

 

7287 - 등록

71
t1mmyt1m

 

2525 - 오븐 시계

h, m = map(int, input().split())
c = int(input())

#if 0<=h<=23 and 0<=m<=59 and 0<=c<=1000:

a, b = (h+((m+c)//60), (m+c))
if b>59:
    print((h+((m+c)//60))%24, b%60)
elif b<59:
    print(a, b)
else:
    print(a, b%60)

 

2530 - 인공지능 시계

a, b, c = map(int, input().split())
i = int(input())

c += i%60
i = i//60
if c >= 60:
    c -= 60
    b += 1

b += i%60
i = i//60
if b >= 60:
    b -= 60
    a += 1

a += i%24
if a >= 24:
    a -= 24


print(a, b, c)

 

2914 - 저작권

a, j = map(int, input().split()) 
print(a * (j - 1) + 1)

 

5355 - 화성 수학

t = int(input())

for _ in range(t):
    n = list(map(str, input().split()))
    
    a = n[0]
    n.remove(a)
    a = float(a)

    for i in range(len(n)):

        if n[i] == '@':
            a *= 3
        elif n[i] == '%':
            a += 5
        elif n[i] == '#':
            a -= 7


    print("%0.2f"%a)

 

2675 - 문자열 반복

s = int(input())

for i in range(s):
    a , b = map(str, input().split())
    a = int(a)

    for j in range(len(b)):
        print(a*b[j], end='')
    print() #줄을 바꾸고 range(s)만큼 반복

 

2935 - 소음

a = int(input())
e = input()
b = int(input())

if e == '+':
    print(a + b)
elif e == '*':
    print(a * b)

 

9498 - 시험 성적

score = int(input())

if score >= 90:
    print("A")
elif 89>= score >= 80:
    print("B")
elif 79>= score >= 70:
    print("C")
elif 69>= score >= 60:
    print("D")
else:
    print("F")

 

10817 - 세 수

a = list(map(int, input().split()))

a.sort(reverse=False)
print(a[1])

 

11653 - 소인수분해

import math

n = int(input())
i = 2

while i <= math.sqrt(n):
    if n % i != 0:
        i += 1
    else:
        print(i)
        n //= i

if n > 1:
    print(n)

 

1789 - 수들의 합

s = int(input())
p = []
a = 1

while True:
    s -= a
    p.append(a)
    a += 1
    if s == 0:
        break
    elif s > 0:
        continue
    else:
        s += p[-1]
        if s in p:
            p.remove(s)
            s += s
            set(p) 
        break

print(len(p))

 

2753 - 윤년

a = int(input())

if 1<=a<=4000:
    if a%4==0 and a%100!=0 or a%400==0:
        print(1)
    else:
        print(0)

 

10039 - 평균 점수

a = []

for _ in range(5):
    a.append(int(input()))

for i in range(5):
    if a[i] < 40:
        a[i] = 40

print(sum(a) // 5)

 

1934 - 최소공배수

import math

def lcm(a, b):
    return a * b // math.gcd(a, b)

line = int(input())

for i in range(line):
    x, y = map(int, input().split())
    print(lcm(x, y))

 

2480 - 주사위 세개

t1, t2, t3 = list(map(int, input().split()))

if t1==t2==t3:
    print(10000 + t1*1000)
elif t1==t2 or t2==t3:
    print(1000 + t2*100)
elif t3==t1:
    print(1000 + t3*100)
else:
    print(max(t1, t2, t3)*100)

 

4101 - 크냐?

while True:
    a, b = list(map(int, input().split()))
    if a > b:
        print("Yes")
    elif a == 0 and b == 0: #
        break
    elif a < b or a == b:
        print("No")

 

10156 - 과자

k, n, m = map(int, input().split())

if k*n <= m:
    print(0)
else:
    print(k*n-m)

 

3009 - 네 번째 점

x, y = [], []

for i in range(3):
    a, b = map(int, input().split())
    x.append(a)
    y.append(b)


i = 0

if x[i] == x[i+1]:
    c = x[i+2]
elif x[i] == x[i+2]:
    c = x[i+1]
elif x[i+1] == x[i+2]:
    c = x[i]
else:
    c = x[i]

if y[i] == y[i+1]:
    d = y[i+2]
elif y[i] == y[i+2]:
    d = y[i+1]
elif y[i+1] == y[i+2]:
    d = y[i]
else:
    d = y[i]

print(c, d)

 

2476 - 주사위 게임

a = int(input())
b = []

for i in range(1, a+1):
    nums = list(map(int, input().split()))
    dup = {x for x in nums if nums.count(x) == 2}
    eup = {x for x in nums if nums.count(x) == 3}
    # 위 코드는 중복되는 숫자를 리스트에 추가하는 코드

    #if nums.count(x) > 1:
    #    for x in nums:
    #        dup.append(x)
    if dup:
        c = 1000+dup.pop()*100 #dup.pop()을 해주는 이유는 set에 있는 숫자인 중복되는 수를 int로 꺼내서 연산하기 위함
        #그냥 dup로 하면 TypeError: unsupported operand type(s) for *: 'set' and 'int' 에러뜸
    elif eup:
        c = 10000+eup.pop()*1000
    else:
        c = max(nums)*100
    b.append(c)

print(max(b))

 

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

1000 - A+B

 

1020

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

1021

#include <stdio.h>

char main()
{
    char data[51]="";
    scanf("%s", &data);
    printf("%s\\n", data);
    return 0;
}

1022

#include <stdio.h>

char main()
{
    char data[2001]="";
    fgets(data, 2000, stdin);
    printf("%s\\n", data);
    return 0;
}

1023

#include <stdio.h>

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

1024

#include <stdio.h>

int main()
{
    int i;
    char d[30];
    scanf("%s", d);
    for(i=0; d[i]!='\\0'; i++)
    {
        printf("\\'%c\\'\\n", d[i]);
    }
}

1025

#include <stdio.h>

int main()
{
    int a, b, c, d, e;
    scanf("%1d %1d %1d %1d %1d", &a, &b, &c, &d, &e);
    printf("[%d]\\n", a*10000);
    printf("[%d]\\n", b*1000);
    printf("[%d]\\n", c*100);
    printf("[%d]\\n", d*10);
    printf("[%d]\\n", e);
    
}

1026

#include <stdio.h>

int main()
{
    int h, m, s;
    
    scanf("%d:%d:%d", &h, &m, &s);
    printf("%d \\n", m);
    return 0;
}

1027

#include <stdio.h>

int main()
{
    int y, m, d;

    scanf("%04d.%02d.%02d", &y, &m, &d);
    printf("%02d-%02d-%04d \\n", d, m, y);
    return 0;
}

1028

#include <stdio.h>

int main()
{
    unsigned int n;

    scanf("%u", &n);
    printf("%u \\n", n);
    return 0;
}

1029

#include <stdio.h>

int main()
{
    double d;

    scanf("%lf", &d);
    printf("%.11lf \\n", d);
    return 0;
}

1030

#include <stdio.h>

int main()
{
    long long int n;

    scanf("%lld", &n);
    printf("%lld \\n", n);
    return 0;
}

1031

#include <stdio.h>

int main()
{
    int n;

    scanf("%d", &n);
    printf("%o \\n", n);
    return 0;
}

1032

#include <stdio.h>

int main()
{
    int n;

    scanf("%d", &n);
    printf("%x \\n", n);
    return 0;
}

1033

#include <stdio.h>

int main()
{
    int n;

    scanf("%d", &n);
    printf("%X\\n", n);
    return 0;
}

1034

#include <stdio.h>

int main()
{
    int n;

    scanf("%o", &n);
    printf("%d\\n", n);
    return 0;
}

1035

#include <stdio.h>

int main()
{
    int n;
    
    scanf("%x", &n);
    printf("%o\\n", n);
    return 0;
}

1036

#include <stdio.h>

int main()
{
    char n;

    scanf("%c", &n);
    printf("%d\\n", n);
    return 0;
}

1037

#include <stdio.h>

int main()
{
    int n;

    scanf("%d", &n);
    printf("%c\\n", n);
    return 0;
}

1038

#include <stdio.h>

int main()
{
    long long int n, a;

    scanf("%lld %lld", &n, &a);
    printf("%lld\\n", n+a);
    return 0;
}

1039

#include <stdio.h>

int main()
{
    long long int n, a;

    scanf("%lld %lld", &n, &a);
    printf("%lld\\n", n+a);
    return 0;
}

'study > C , C++' 카테고리의 다른 글

코드업 C언어 기초 100제 1001~1019  (0) 2023.02.13

1009와 1016은 문제번호에 없었다..

1001

#include <stdio.h>

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

1002

#include<stdio.h>

int main() {
    printf("Hello World\\n");
    return 0;
}

1003

#include<stdio.h>

int main(){
    printf("Hello\\nWorld\\n");
    return 0;
}

1004

#include<stdio.h>

int main(){
    printf("\\'Hello\\'\\n");
    return 0;
}

1005

#include<stdio.h>

int main() {
    printf("\\"Hello World\\"\\n");
    return 0;
}

1006

#include <stdio.h>

int main(){
    printf("\\"!@#$%%^&*()\\"\\n");
    return 0;
}

1007

#include <stdio.h>

int main(){
    printf("\\"C:\\\\Download\\\\hello.cpp\\"\\n");
    return 0;
}

1008

#include <stdio.h>
int main()
{
    printf("\\u250C\\u252C\\u2510\\n\\u251C\\u253C\\u2524\\n\\u2514\\u2534\\u2518\\n");
    return 0;
}

1010

#include <stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    printf("%d\\n", n);
    return 0;
}

1011

#include <stdio.h>
char main()
{
    char x;
    scanf("%c", &x);
    printf("%c\\n", x);
    return 0;
}

1012

#include <stdio.h>
float main()
{
    float x;
    scanf("%f", &x);
    printf("%f\\n", x);
    return 0;
}

1013

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

1014

#include <stdio.h>
char main()
{
    char a, b;
    scanf("%c %c", &a, &b);
    printf("%c %c\\n", b, a);
    return 0;
}

1015

#include <stdio.h>
float main()
{
    float a;
    scanf("%f", &a);
    printf("%.2f\\n", a);
    return 0;
}

1017

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

1018

#include <stdio.h>
int main()
{
    int h, m;
    scanf("%d:%d", &h, &m);
    printf("%d:%d\\n", h,m);
    return 0;
}

1019

#include <stdio.h>
int main()
{
    int y, m, d;
    scanf("%d.%d.%d", &y, &m, &d);
    printf("%04d.%02d.%02d\\n", y,m,d);
    return 0;
}

'study > C , C++' 카테고리의 다른 글

코드업 C언어 기초 100제 1020~1039  (0) 2023.02.13