hahahia

ab + ba = 99 를 만족하는 a, b값 구하는 프로그램 본문

Language/C

ab + ba = 99 를 만족하는 a, b값 구하는 프로그램

hahahia 2011. 5. 13. 10:21

/* made by hahahia */

 

#include <stdio.h>

 

void main()

{

        int i, j;

        for(i=0; i<=9; i++) {

               for(j=0; j<=9; j++) {

                       if(i*10 + j + j*10 + i == 99)

                       {

                              if(i == 0)

                              {

                                      printf("%d + %d%d = 99\n", j , j , i);

                                      printf("a = %d, b = %d\n", i , j);

                              }

                              else if(j==0)   

                              {

                                      printf("%d + %d%d = 99\n", i , i , j);

                                      printf("a = %d, b = %d\n", i , j);

                              }

                              else {

                                      printf("%d%d + %d%d = 99\n", i,j, j,i);

                                      printf("a = %d, b = %d\n", i, j);

                              }

                       }

               }

        }

}

 

Comments