分别使用for循环、while循环和do…while循环三种循环语句编写程序,输出九九乘法口诀表,
答案:1 悬赏:20 手机版
解决时间 2021-11-16 06:45
- 提问者网友:焚苦与心
- 2021-11-15 09:28
分别使用for循环、while循环和do…while循环三种循环语句编写程序,输出九九乘法口诀表,
最佳答案
- 五星知识达人网友:怀裏藏嬌
- 2021-11-15 09:48
//---------------------------------------------------------------------------
#pragma hdrstop
#include
#include
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
printf("\n\nfor:\n");
for (int i=1;i<=9;i++)
{
for (int k=i;k<=9;k++)
printf("%d*%d=%d ",i,k,i*k);
printf("\n");
}
printf("\n\nwhile:\n");
int i=1;
while (i<=9)
{
int k=i;
while (k<=9)
{
printf("%d*%d=%d ",i,k,i*k);
k++;
}
i++;
printf("\n");
}
printf("\n\ndo...while:\n");
i=1;
do
{
int k=i;
do
{
printf("%d*%d=%d ",i,k,i*k);
k++;
} while (k<=9);
i++;
printf("\n");
} while (i<=9);
getch();
return 0;
}
//---------------------------------------------------------------------------
#pragma hdrstop
#include
#include
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
printf("\n\nfor:\n");
for (int i=1;i<=9;i++)
{
for (int k=i;k<=9;k++)
printf("%d*%d=%d ",i,k,i*k);
printf("\n");
}
printf("\n\nwhile:\n");
int i=1;
while (i<=9)
{
int k=i;
while (k<=9)
{
printf("%d*%d=%d ",i,k,i*k);
k++;
}
i++;
printf("\n");
}
printf("\n\ndo...while:\n");
i=1;
do
{
int k=i;
do
{
printf("%d*%d=%d ",i,k,i*k);
k++;
} while (k<=9);
i++;
printf("\n");
} while (i<=9);
getch();
return 0;
}
//---------------------------------------------------------------------------
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯