程序,用于在C ++中查找车轮图的直径,周期和边缘
例
#include <bits/stdc++.h>
using namespace std;
//计算周期数
int totalCycle(int vertices) {
int result = 0;
result = pow(vertices, 2) - (3 * vertices) + 3;
return result;
}
//计算边数
int Edges(int vertices) {
int result = 0;
result = 2 * (vertices - 1);
return result;
}
//计算直径
int Diameter(int vertices) {
int result = 0;
if (vertices == 4)
result = 1;
else
result = 2;
return result;
}
int main() {
int vertices = 4;
cout << "Number of Cycle = " << totalCycle(vertices) << endl;
cout << "Number of Edges = " << Edges(vertices) << endl;
cout << "Diameter = " << Diameter(vertices);
return 0;
}输出结果
Number of Cycle = 7 Number of Edges = 6 Diameter = 1
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短