cr:经典
题目11
将一个正整数分解质因数。例如: 输入90,打印出90=2*3*3*5。
思路:
这个题目我是没有什么思路的,我打算先看一下C站前人的做法。
实话说,看完之后我还是没理解这个题目到底怎么做。再看看B站的吧。
对方:![](https://i-blog.csdnimg.cn/blog_migrate/1cae6a31b6dfcb10b5b9cd984ac72d87.png)
反思&收获:
看完之后大概明白了,知道了代码如何实现,但是我对质因数 这个概念还是不太懂。质因数
https://baike.baidu.com/item/%E8%B4%A8%E5%9B%A0%E6%95%B0/6192269?fr=aladdin
代码:![](https://i-blog.csdnimg.cn/blog_migrate/945c170b92fd8baba1a84568768ad6e6.png)
cr:小林
例11
C语言实现求1+2+3+…+…+100的和,要求分别用while、do while、for循环实现。
思路:
要实现从1加到100分别用三种方法。
代码:
#include<stdio.h>
main()
{
printf("使用for:\n");
int i, result = 0;
for (i = 1; i < 101; i++) {
result += i;
}
printf("从1加到100的结果是 %d \n", result);
printf("\n使用while:\n");
int i2 = 1, result2 = 0;
while (i2 < 101) {
result2 += i2;
i2++;
}
printf("从1加到100的结果是 %d \n", result2);
printf("\n使用do-while:\n");
int i3 = 1, result3 = 0;
do {
result3 += i3;
i3++;
} while (i3 < 101);
printf("从1加到100的结果是 %d \n", result3);
}
对方:![](https://i-blog.csdnimg.cn/blog_migrate/19cbab8478a89d9917ec24ac943044d4.png)
反思&收获:
注意变量的使用。