C语言网习题
https://www.dotcpp.com/oj/problemset.php?page=1&mark=6# 题目 1084: 用筛法求之N内的素数。 C++ #include<iostream> using namespace std; int main() { int N; cin >> N; if (N >= 2) cout << 2 << endl; //外循环 for (int …
461 2020-10-20 0
去围观
STL-泛型算法
<algorithm>涉及比较、交换、查找、遍历操作、赋值、修改、移除、反转、排序、合并等等 <numeric>在序列上面进行简单数学运算,包括加法和乘法在序列上的一些操作 <functional>定义了一些模板类,用以声明函数对象 常见的STL算法 #include<ios…
457 2020-10-15 0
去围观
STL-迭代器
分类 输出输出迭代器 输出迭代器 只能一次一个向前读取元素,按此顺序一个个传回元素值 表达式功能表述*iter读取实际元素iter->member读取实际元素的成员(有的话)++iter向前步进(传回新位置)iter++向前步进(传回旧位置)iter1 == iter2判断两个迭代器…
380 2020-10-15 0
去围观
STL-容器
定义了函数调用操作符的对象,又称仿函数。 使一个类的使用看上去像一个函数,其实现就是类中实现一个operator() 这个类就有了类似函数的行为 #include<iostream> #include<string> using namespace std; class X { public: void operator()(string …
402 2020-10-14 0
去围观
Chapter2-贪心算法
#include<iostream> #include<algorithm> using namespace std; int main() { double c; int n; cout << "请输入载重总量及古董个数:"; cin >> c >> n; int* a = new int(n); cout << "请输入每件物品重量,用空格隔开:"; for (int i = 0; i …
416 2020-09-29 0
去围观
第二章-应用程序接口
测试程序 茶壶 #include<GL/glut.h> using namespace std; int main(int argc,char** argv) { void SetupRC(); void RenderScene(); glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE);//设置颜色缓冲区及颜色模式 glutInitW…
435 2020-09-19 0
去围观
Chapter 1-算法之美
1、算法复杂性 #include<iostream> using namespace std; int main() { int fac(int n); int x = 5; int result = fac(x); cout << "5的阶乘是:" << result; return 0; } // 递归计算阶乘 int fac(int n) { if (n < 0) …
425 2020-09-17 0
去围观