#include <stdio.h>
int main()
{
int iN1;
int iN2;
int iN3;
printf("몇 단의 구구단을 보시겠습니까?: ");
scanf("%d",&iN1);
iN2=1;
while(iN2 <= 9)
{
iN3=iN1*iN2;
printf("%d X %d = %d\n",iN1,iN2,iN3);
iN2++;
}
printf("\n");
return 0;
}
2.구구단 전체 출력
#include <stdio.h>
int main()
{
int iN1;
int iN2;
printf("2단에서 9단까지 구구단 출력\n");
iN2=2;
while(iN2 <= 9)
{
iN1=1;
while(iN1 <= 9)
{
printf("%d X %d = %1d\t",iN2,iN1,iN1*iN2);
iN1++;
}
iN2++;
}
printf("\n");
return 0;
}
3.구구단 일부 A~B 출력
#include <stdio.h>
int main()
{
int iN1;
int iN2;
int iA;
int iB;
printf("A단에서 B단까지 구구단 출력\n");
printf("A= ");
scanf("%d",&iA);
printf("B= ");
scanf("%d",&iB);
iN2=iA;
while(iN2 <= iB)
{
iN1=1;
while(iN1 <= 9)
{
printf("%d X %d = %1d\t",iN2,iN1,iN1*iN2);
iN1++;
}
iN2++;
}
printf("\n");
return 0;
}
|
|
|