C++程序设计基础
一花一世界*
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
printf返回值
#include<stdio.h> int main() { printf("\n%d\n", printf("Hello world!")); } 解析:printf("\n%d\n", printf(“Hello world!”)); printf()是一个函数,所以他在实现自己功能(输出字符串)的同时也有返回值,他的返回值就是printf打印的字符个数 例如:printf...原创 2019-10-14 20:31:42 · 763 阅读 · 0 评论 -
C++一个解决方案解决多个小题
学习过程中总是在做一个文件就能完成的“小”程序,而如果想要将他们都保存起来每次都需要建立一个新项目,这样即费时间又费内存。 为此我想到了一个,可以在一个解决方案中运行多个“小”程序的方案。 这就是,“小”程序 这是主函数,每次使用将第一行最后的fun1改为“小”程序对应的fun序号即可 例如:这里有两个“小”程序 当我想运行第一个时,把主函数改为 在这里插入图片描述 当我想运行第二个时,将主程序...原创 2019-10-14 10:07:16 · 423 阅读 · 0 评论 -
C++求PI π
C++求π #include<cmath> using namespace std; int main() { double sum = 0, x = 1, i = 1; //sum表示各项的和,x表示各项,i表示第几项 while (fabs(x) > 0.000001) { x = 1 / (2 * i - 1) * pow(-1, i - 1); /...原创 2019-10-14 09:37:07 · 1899 阅读 · 0 评论 -
C++辗转相除法求最大公约数
C++辗转相除法求最大公约数 #include<iostream> using namespace std; int main() { int a, b; cin >> a >> b; if (a < b) //使输入的两个数a大于b { int t = a; a = b; b = t; } while (b != 0) ...原创 2019-10-14 08:56:13 · 2012 阅读 · 0 评论 -
C++程序设计基础 小母牛问题
C++例题,小母牛问题。 C++编程求解问题。若一头小母牛,从出生起第四个年头开始每年生一头母牛,按此规律,第n年时有多少头母牛? #include<iostream> using namespace std; int main() { while (1) { int n; cout << "有一头母牛" << endl; cout <&l...原创 2019-10-08 20:02:32 · 4570 阅读 · 0 评论 -
C++编程打印九九乘法表
C++编程打印九九乘法表 #include<iostream> using namespace std; int main() { cout << '\t' << '*'; for (int i = 1; i <= 9; i++) //输出第一行 cout << '\t' << i; cout << end...原创 2019-10-08 20:27:20 · 6136 阅读 · 0 评论
分享