- 博客(9)
- 收藏
- 关注
原创 *
#include<iostream>using namespace std;int main() { int n, r, i,k; // i是行数,只需要考虑前面的空 cin >> n; i = 1; for (; i <= n; i++) { for (r = n - i; r >= 1; r = r - 1) cout << " "; for (k = 1; k <= 2 * i - 1; k++)
2020-11-16 00:05:17 58
原创 计算正数个数和平均数
#include<iostream>using namespace std;int main() { int a, i, number,s; //S是十个数的和 number = 0; s = 0; cout << "请输入十个数" << std::endl; for (i = 1; i <= 10; i++) { cin >> a; s += a; if (a > 0) { number++; }
2020-11-14 21:26:25 320
原创 判断素数
#include<iostream>#include<cmath>using namespace std;int main() { int a, b, i; i = 2; cout << "请输入一个数"; cin >> a; do { b = a % i; i++; if (b == 0) { cout << "不是"; break; } else continue; } while (i <
2020-11-13 20:36:32 66
原创 输出数列
#include<iostream>using namespace std;int main() { int a, b, c; for (a=0; a <= 3;) { a++; for (b = 1; b <= 5; b++) cout << a * b << " "; cout << endl; } return 0;}在这里插入代码片
2020-11-13 18:40:17 373
原创 圆面积不大于100
#include<iostream>#include<ctime>using namespace std;int main() { double pi, radius, area; pi = 3.1415926; radius = 1; area = 0; while (area <= 100){ area = pi * radius * radius; radius++; } cout <<area; return 0;}
2020-11-13 13:02:35 174
原创 1000以内水仙花数
#include<iostream>#include <cmath>using namespace std;int main() { int s, a, b, c; for (s = 100; s <= 999; s++) { a = s % 10; b = (s / 10) % 10; c = s / 100; if (s == a * a * a + b * b * b + c * c * c) cout << "水仙花数为" &
2020-11-13 13:00:14 96
原创 累加到N
#include<iostream>using namespace std;int main() { int N,i,sum; do { sum = 0; cin >> N; for (i = 1; i <= N; i++) { sum += i; } cout << sum; } while (N >= 0);}
2020-11-13 12:55:55 123
原创 海伦公式 面积
#include#includeusing namespace std;int main() {int a, b ,c,p,s;cout << “请输入三边长:” << std::endl;cin >> a >> b >> c;p = (a + b + c) / 2;s = sqrt(p * (p - a) * (p - b) * (p - c));cout << “s=” << s;}...
2020-11-13 12:53:24 116
原创 比较大小
#includeusing namespace std;int main() {double a, b, c;double max, min;cout << “请输入三个实数” << std::endl;cin >> a >> b >> c;if (a > b) {max = a;min = b;}else max = b;min = a;if (max < c) {cout << c <&
2020-11-13 12:50:39 60
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人