#include <iostream>
#include <cmath>
//We will use sqrt function.
//原理:输入数字和符号;经过计算后,给出多余数字和最外层字符显示数;利用最外层字符显示数逐行输出,显示多余数字。
//The core princple: First, we import the number and the character; and after calculating, we can get
//the redundance value (acronym: RedunVal) and the number of characters of the first row
//(acronym: FirRowCharNum); Finally, we utilize FirRowCharNum to display characters row by row and RedunVal.
//输入函数 The input function of two data
void input2(int& num, char& ch) {
std::cin >> num;
std::cin >> ch;
}
//计算函数 The calculating function: the result is the change of RedunVal and FirRowCharNum.
void calculating(int num,int& RedunVal, int& FirRowCharNum) {
//数字逐个减去一,2*三,2*五,2*七……,直到它变成负数,知道RedunVal是多少了
//Subtract 1,2*3,2*5,2*7... from num succesively until the difference is negatice,
//then we can get RedunVal.
//倒数第二个充当减数的奇数,就是FirR
团体程序设计天梯赛-练习集 L1-002 打印沙漏(C++)
最新推荐文章于 2022-12-15 10:27:28 发布
这篇博客详细介绍了如何使用C++编程语言来实现打印沙漏图案的算法,包括其逻辑步骤和代码实现,适合初学者提升编程技能。
摘要由CSDN通过智能技术生成