第一题
#include<iostream>
using namespace std;
int main()
{
double a, b, c, max, min;
cin >> a >> b >> c;
if (a < b) {
max = b;
min = a;
}
else {
max = a;
min = b;
}
if (c > max) {
cout << c << '\t' << max << '\t' << min << '\n';
}
else if (min > c)
{
cout << max << '\t' << min << '\t' << c << '\n';
}
else {
cout<< max << '\t' << c << '\t' << min << '\n';
}
return 0;
}
第二题
#include<iostream>
using namespace std;
int main() {
cout << "请输入三边的长" << endl;
double a, b, c, p, S;
cin >> a >> b >> c;
p = (a + b + c) / 2;
S = p * (p - a) * (p - b) * (p - c);
S = sqrt(S);
cout << S << endl;
return 0;
}
第三题
#include<iostream>
using namespace std;
int main() {
for(int a=1;a<10;a++){
for (int b = 0; b < 10; b++) {
for (int c = 0; c < 10; c++) {
if ((a * 100 + b * 10 + c) == (a * a * a + b * b * b + c * c * c)) {
cout << a * 100 + b * 10 + c << endl;
}
}
}
}
return 0;
}
第四题
#include<iostream>
using namespace std;
int main() {
int N=0, sum = 0;
while (1){
int sum = 0;
cin >> N;
for (int i = 0; i <= N; i++)
sum += i;
cout << sum << endl;
if (N < 0)break;
}
return 0;
}
第五题
#include<iostream>
using namespace std;
int main() {
for (int a = 1; a <= 4; a++) {
for (int b = 1; b <= 5; b++) {
int c;
c = a * b;
cout << c << '\t';
}
cout << endl;
}
return 0;
}
第六题
#include<iostream>
using namespace std;
int main() {
int a, t = 0, sum = 0, average;
for (int i = 1; i <= 10; i++) {
cin >> a;
sum += a;
if (a > 0) {
t++;
}
else continue;
}
average = sum / 10;
cout << t << endl;
cout << average << endl;
return 0;
}
第七题
#include<iostream>
using namespace std;
int main() {
double S,radius = 1;
for (; radius <= 10; radius++) {
S = 3.14 * radius * radius;
if (S > 100) break;
cout << S << endl;
}
return 0;
}
第八题
#include<iostream>
using namespace std;
int main() {
int m;
int n;
cin >> m;
n = sqrt(m);
for (int i = 2; i <= n; i++) {
if ((m % i) == 0) {
cout << " no " << endl;
break;
}
else {
cout << "yes" << endl;
break;
}
}
return 0;
}
第九题
#include<iostream>
using namespace std;
int main() {
int i = 101, m, t = 0;
for (; i <= 200; i+=2) {
m = sqrt(i);
for (int n = 3; n <= m; n++) {
if ((i % n) == 0) {
break;
}
else {
t++;
cout << i << " ";
if (t % 5 == 0)
cout << endl;
break;
}
}
}
return 0;
}
第十题
#include<iostream>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 1; i <= (2*n-1); i++) {
if(i<=n){
for (int t = 1; t <= (2 * n - 1); t++) {
for (; t <= (n - i) || t >= (n + i);) {
cout << " ";
if (t == (2 * n - 1))
cout << endl;
break;
}
for (; t > (n - i) && t < (n + i);) {
cout << "*";
break;
}
}
}
else {
cout << endl;
for (int m = 1; m <= (2 * n - 1); m++) {
for (; m <= (i - n) || m>=(3 * n- i);) {
cout << " ";
break;
}
for (; m > (i - n) && m <(3 * n - i);) {
cout << "*";
break;
}
}
}
}
return 0;
}