输出字符菱形
#include <iostream>
using namespace std;
int main()
{int n;//cin >> n;n = 5;int up = n / 2;int down = n - up;//打印上半部分for (int i = 0; i < down; i++) {for (int j = 0; j < down-1-i; j++) {cout << " ";}for (int j = 0; j < 2 * i + 1; j++) {cout << "*";}cout << endl;}//打印下半部分for (int i = 0; i < up; i++) {for (int j = 0; j < i + 1; j++) {cout << " ";}for (int j = 0; j < (n - 2 - 2 * i); j++) {cout << "*";}cout << endl;}return 0;
}
字符三角形
#include <iostream>
using namespace std;
int main()
{char x;cin >> x;int n;//cin >> n;n = 5;int up = n / 2;int down = n - up;for (int i = 0; i < down; i++) {for (int j = 0; j < down-1-i; j++) {cout << " ";}for (int j = 0; j <2*i+1; j++) {cout << x;}cout << endl;}return 0;
}
上学迟到
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{int s, v;int t;cin >> s >> v;if (s % v == 0) {t = s / v;t += 9;//从07:59开始}else {t = s / v;t = t + 9 + 1;//不能整除,多加一个1}int H = 7, M = 59;while (t--) {if (M != 0) {M--;}else {if (H != 0) {H--;M = 59;}else {H = 23;M = 59;}}}//分开保存小时和分钟的十位和个位int h1 = H / 10;int h2 = H % 10;int m1 = M / 10;int m2 = M % 10;cout << h1 << h2 << ":" << m1 << m2 << endl;return 0;
}
小鱼游泳
#include <iostream>
using namespace std;
int main()
{int h1, h2, m1, m2;cin >> h1 >> m1 >> h2 >> m2;int t1 = h1 * 60 + m1;int t2 = h2 * 60 + m2;int t = t2 - t1;cout << t / 60 << " " << t % 60 << endl;return 0;
}
其他的几道题目太简单了,没有写