乘法表
原创
©著作权归作者所有:来自51CTO博客作者刘文斌3313的原创作品,谢绝转载,否则将追究法律责任
1. 乘法表
① int sum = 0;
for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= i; j++)
{
sum = i * j;
if (j==2)
{
if (sum == 6)
{
Label1.Text += j.ToString() + "x" + i.ToString() + "=" + sum.ToString() + " ";
}
else if (sum == 8)
{
Label1.Text += j.ToString() + "x" + i.ToString() + "=" + sum.ToString() + " ";
}
}
else
{
Label1.Text += j.ToString() + "x" + i.ToString() + "=" + sum.ToString() + " ";
}
}
Label1.Text += "</br>";
}
②
Label1.Text = "";
int sum;
string s2;
string[] chengfa={"十","一","二","三","四","五","六","七","八","九"};
for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= i; j++)
{
sum = i * j;
if (sum < 10)
{
if (j == 2)
{
Label1.Text += chengfa[i] + chengfa[j] + "得" + chengfa[sum] + " ";
}
else
{
Label1.Text += chengfa[i] + chengfa[j] + "得" + chengfa[sum] + " ";
}
}
else
{
if (sum % 10 == 0)
{
s1 = sum.ToString().Substring(0, 1);
s2 = sum.ToString().Substring(1, 1);
Label1.Text += chengfa[i] + chengfa[j] + chengfa[Convert.ToInt32(s1)] + chengfa[Convert.ToInt32(s2)] + " ";
}
else
{
s1 = sum.ToString().Substring(0, 1);
s2 = sum.ToString().Substring(1, 1);
Label1.Text += chengfa[i] + chengfa[j] + chengfa[Convert.ToInt32(s1)] + "十" + chengfa[Convert.ToInt32(s2)] + " ";
}
}
}
Label1.Text += "</br>";
}
下一篇:35选7中奖查询
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
打印乘法表程序
-
九九乘法表,简单html
九九乘法表html
html 九九乘法表 -
PHP如何实现99乘法表?
看到这个问题,可能大家更多的是考虑到用for循环,个人觉得使用for循环太影响程序性
ide for循环 微信公众号