1.任务和代码:
/*
*文件名称:cheng_he.c
*作 者:末子灬秋风
*完成时间:2020年4月14日
*版本 号:vc++6.0
*
*问题描述:输出1至100之间每位数的乘积大于每位数的和的数。
*程序输出:输出特定要求的数。
*/
#include<stdio.h> /*标准I/O库*/
/*主函数*/
int main()
{
/*定义变量*/
int x; /*运行的数*/
int n; /*输出结果的个数*/
int wei_cheng; /*位乘*/
int wei_he; /*位和*/
int ten,ind; /*ten是十位,ind是个位*/
/*初步计算*/
wei_cheng=(ten*ind); /*求位乘*/
wei_he=(ten+ind); /*求位和*/
/*输出提示*/
printf("在1~100中,位乘>位和的数有:\n");
/*循环并判断*/
for(x=1;x<=100;x++)
{
ten=(x/10); /*求十位*/
ind=(x%10); /*求个位*/
if(wei_cheng>wei_he)
{
printf("%5d",x); /*输出结果长度为5*/
/*整齐排列,5个一行*/
n++; /*每输出一个结果+1*/
if((n%5)==0)
{
printf("\n");
}
}
}
/*空一行*/
printf("\n");
return 0;
}
2.运行结果:
3.知识点总结:
①:注意定义变量是要清晰明了,整洁。
②:注意内外的循环嵌套。
③:整齐排列的方法,5个排一行。
④:块与块之间要空行,注意区分。
4.心得:
①:要逐步积累小技巧,整洁高效很重要。
②:要思考多种方法解决问题。