Computer Science/Algorithm & Data Structures

백준 2438번

www.acmicpc.net/problem/2438 2438번: 별 찍기 - 1 첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 찍는 문제 www.acmicpc.net Comment : for문의 시작은 별찍기부터가 아닐까 생각이 든다. #include int main() { int a , b , c , i=1; scanf("%d" , &a); for(b=1; b

Computer Science/Algorithm & Data Structures

백준 11022번

www.acmicpc.net/problem/11022 11022번: A+B - 8 각 테스트 케이스마다 "Case #x: A + B = C" 형식으로 출력한다. x는 테스트 케이스 번호이고 1부터 시작하며, C는 A+B이다. www.acmicpc.net Comment : for문을 사용해 테스트케이스 제한하는것이 흥미로운 문제 #include int main() { int T , I , A , B; scanf("%d" , &T); for(I=1; I

Computer Science/Algorithm & Data Structures

백준 2742번

www.acmicpc.net/problem/2742 2742번: 기찍 N 자연수 N이 주어졌을 때, N부터 1까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오. www.acmicpc.net Comment: 2741번인 문제의 응용. 마찬가지로 for원리를 이해하고 있다면 쉽게 풀 수있다. #include int main() { int n; scanf("%d" , &n); for(; n>0; n--) { printf("%d\n" , n); } return 0; }

Computer Science/Algorithm & Data Structures

백준 2741번

www.acmicpc.net/problem/2741 2741번: N 찍기 자연수 N이 주어졌을 때, 1부터 N까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오. www.acmicpc.net Comment: for문의 단계별 알고리즘을 잘 이해하고 있으면 쉽게 풀 수 있는 문제 #include int main() { int n , i; scanf("%d" , &n); for(i=1; i

Computer Science/Algorithm & Data Structures

백준 8393번

www.acmicpc.net/problem/8393 8393번: 합 n이 주어졌을 때, 1부터 n까지 합을 구하는 프로그램을 작성하시오. www.acmicpc.net Comment : 1~n까지의 합을 구하는 문제이다. 고딩 떄 합공식을 배웠으면 매우 쉽게 풀 수 있는 문제. #include int main() { int n,s; scanf("%d" , &n); if( (n10000) ) printf("ERROR"); s = n*(n+1)/2; printf("%d" , s); }

Computer Science/Algorithm & Data Structures

백준 2739번

www.acmicpc.net/problem/2739 2739번: 구구단 N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다. www.acmicpc.net Comment : for문의 기초이며 매우 쉽게 풀수 있었던 문제 #include int main() { int a , n; scanf("%d" , &a); for(n=1; n