Algorithm/goorm

goorm 완전수, 부분문자열, 대소문자 바꾸어 출력하기

마띠(쥔장) 2020. 8. 26. 16:42

#include <iostream>
using namespace std;
int main(void) {
	int a, b; // a=6 b=100
	cin >> a >> b; // 6~100
	for(int i = a; i <= b; i++){ // i = 6 ~ 100 1씩 증가 
		int sum = 0; // 0
		for(int j = 1; j < i; j++){ // j=1 2 3 부터 5까지 돎
			if(i % j == 0)
				sum += j;
		}
		if(sum==i)
				cout<<i<<" ";
	}
}

 

# -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
s = input()
for i in range (len(s)):
	print (s[:(i+1)])

 

#include <iostream>
#include <cstdlib>
using namespace std;
int main(void){
	string str = "";
	cin >> str;
	int i;
 	for(i=0; i < str.size(); i++){
		if(97 <= int(str[i]) )
			 str[i]=toupper(str[i]); //소문자를 대문자로 교환
		else
			str[i]=tolower(str[i]);
	}
	cout<<str<<endl;
}
728x90