마이크로비트에는 내장되어 있는 온도센서가 있습니다. 이를 이용해서 


온도가 27도 이하이면 웃는 표정을, 그 이상 올라가면 화난 표정을 LED에 표현하기


하는 코드를 짜보았습니다. 





#include<iostream>  

using namespace std;

int fun(int k);
int main(void)
{
	int forans[20000];
	for(int i=0;i<10000;++i)
	{
		forans[i] = i+1;
	}
	
	int a,k = 1;
	while(k!=10000){
		a=k;
		while(a<10000)
		{
			a=fun(a);
			forans[a-1] = -1;
			
		}
		k++;
	}
	
	for(int i=0;i<10000;++i)
		if(forans[i]!=-1)
			cout << forans[i] << endl;
    
    return 0;
}

int fun(int k)
{
	int a1=0,a2=0,a3=0,a4=0;
	if(k>=1000){
		a1 = k/1000;
		a2 = (k - a1 * 1000)/100;
		a3 = (k - a1 * 1000 - a2 * 100)/10;
		a4 = k%10;
	}
	else if(k>=100){
		a2 = k/100;
		a3 = (k - a2 * 100)/10;
		a4 = k%10;
	}
	else if(k>=10){
		a3 = k/10;
		a4 = k%10;
	}
	else{
		a4 = k;
	}
	
	int forreturn;
	
	forreturn = k+a1+a2+a3+a4;
	
	return forreturn;
	
	
}
 


'알고리즘' 카테고리의 다른 글

[그래프] 백준 5567 결혼식  (0) 2017.12.13
[EAZY] 백준 1065번 한수  (0) 2017.08.17
백준 C++ 11721번  (0) 2017.08.15
백준 C++ 11720번  (0) 2017.08.15
백준 C++ 11719번  (0) 2017.08.15

#include <iostream>  
#include 

using namespace std;

int main(void)
{
	int l;
	char c[1000];
	cin >> c;
	for(l=0;l<100;++l)
	{
		if (c[l] == '\0')
			break;
	}
		
	
	for (int i = 0; i < l ; ++i)
	{
		cout << c[i];
		if ((i+1) % 10 == 0)
			cout << endl;
	}

}


 


'알고리즘' 카테고리의 다른 글

[EAZY] 백준 1065번 한수  (0) 2017.08.17
[EAZY] 백준 4673 셀프넘버  (0) 2017.08.15
백준 C++ 11720번  (0) 2017.08.15
백준 C++ 11719번  (0) 2017.08.15
백준 C++ 11718번  (0) 2017.08.15

+ Recent posts