C 언어 고전 100 예 연습 사례 1

http://www.runoob.com/cprogramming/c-exercise-example1.html
제목: 1, 2, 3, 4 개의 숫자 가 있 는데 서로 다 르 고 중복 되 지 않 는 세 자릿수 를 구성 할 수 있 습 니까?다 얼마예요?
 
코드 는 다음 과 같 습 니 다:
#include 
int main()
{
	int a,b,c,count=0;;
	for(a=1;a<=4;a++)
	{
		for(b=1;b<=4;b++)
		{
			for(c=1;c<=4;c++)
			{

				if(a!=b && a!=c && b!=c){
					count++;
					printf("%d
",a*100+b*10+c*1); } } } } printf("%d",count); }

 
결과: 123 124 132 134 142 143 213 214 231 241 243 312 321 324 341 342 412 413 421 423 431 432 24

좋은 웹페이지 즐겨찾기