C++
UnspoKen995
职业dalao腿部挂件
展开
-
2668-Point类的定义
#include <bits/stdc++.h>#define Max 1010000using namespace std;class Point{ int x,y;public: void SetPoint(int x, int y) { this->x = x; this->y = y; } void ShowPoin原创 2017-09-23 00:29:03 · 307 阅读 · 0 评论 -
2673-计算长方形的周长和面积
#include <bits/stdc++.h>using namespace std;class Rect{private: double Length, Width;public: Rect(double l = 0, double w = 0) { if(l >= 0 && w >= 0) { Length原创 2017-09-29 00:31:39 · 199 阅读 · 0 评论 -
2674-学生成绩统计
#include <bits/stdc++.h>using namespace std;class Student{private: int id, math, english, computer; char name[20];public: int sum() { return math + english + computer; }原创 2017-09-29 00:32:34 · 179 阅读 · 0 评论 -
2675-静态数据成员与静态成员函数
#include <bits/stdc++.h>using namespace std;class Point{private: double x, y; static int count;public: Point(int x = 0, int y = 0) { this->x = x; this->y = y;原创 2017-09-29 00:32:59 · 190 阅读 · 0 评论 -
类的友元函数的应用
3-7 类的友元函数的应用#include <bits/stdc++.h>using namespace std;class Point{private: double x, y;public: Point(double x = 0, double y = 0); void Output(const char *name); friend void Distanc原创 2017-10-27 09:26:32 · 181 阅读 · 0 评论 -
1254-面向对象程序设计上机练习八(对象数组)
面向对象程序设计上机练习八(对象数组)#include <bits/stdc++.h>using namespace std;class Stu{private: char ID[20]; int gra;public: void getData(char id[], int gra) { strcpy(ID, id); //thi原创 2017-10-27 10:06:10 · 189 阅读 · 0 评论 -
1271-面向对象程序设计上机练习九(对象指针)
面向对象程序设计上机练习九(对象指针)#include <bits/stdc++.h>using namespace std;int maxn = 0;char t[20];class Stu{private: char ID[20]; int gra;public: void getData(char id[], int gra) { strc原创 2017-10-27 10:13:48 · 195 阅读 · 0 评论 -
避免头文件复用-#pragma once与#ifndef的区别
转载自“百度百科” #pragma once 这是一个比较常用的指令,只要在头文件的最开始加入这条指令就能够保证头文件被编译一次 #pragma once用来防止某个头文件被多次include,#ifndef,#define,#endif用来防止某个宏被多次定义。 #pragma once是编译相关,就是说这个编译系统上能用,但在其他编译系统不一定可以,也就是说移植性差转载 2018-01-05 22:04:32 · 482 阅读 · 1 评论 -
有关C/C++未定义行为
未定义行为(undefined behavior)在计算机程序设计中,未定义行为(英语:undefined behavior)是指行为不可预测的计算机代码。原创 2018-01-10 16:25:40 · 355 阅读 · 0 评论 -
2672-构造函数的调用(高级)
#include <bits/stdc++.h>using namespace std;class A{public: A() { cout << "constructing an object of A" << endl; } ~A() /*析构函数:在作用域结束后执行*/ { cout << "Destructing a原创 2017-09-29 00:31:05 · 176 阅读 · 0 评论 -
2233-构造函数的调用
#include <bits/stdc++.h>using namespace std;class A{public: A() { cout << "Constructing an object of A" << endl; } ~A() /*析构函数:在作用域结束后执行*/ { cout << "Destructing a原创 2017-09-29 00:30:39 · 114 阅读 · 0 评论 -
2669-Time类的定义
#include <bits/stdc++.h>#define Max 1010000using namespace std;class Time{private: int hour, minute, second; void setHour(int x) { if(x > 1 && x <= 12) { hour原创 2017-09-23 00:29:30 · 161 阅读 · 0 评论 -
1144-面向对象程序设计上机练习五(类和对象)
#include <bits/stdc++.h>#define Max 1010000using namespace std;class Time{private: int hour, minute, second; void setHour(int x) { if(x > 1 && x <= 12) { hour原创 2017-09-23 00:30:00 · 318 阅读 · 0 评论 -
2710-输出菱形
#include <bits/stdc++.h>using namespace std;int main(){ int n; while(cin >> n) { for(int i = 0; i < n; i++) { for(int j = n-i-1; j > 0; j--) {原创 2017-09-15 09:27:20 · 137 阅读 · 0 评论 -
1140-面向对象程序设计上机练习一(函数重载)
#include <bits/stdc++.h>using namespace std;int Sort(int n);float Sort(float n);long Sort(long n);int main(){ int a; float b; long c; cin >> a; Sort(a); cin >> b; Sort(b);原创 2017-09-15 09:28:02 · 274 阅读 · 0 评论 -
1141-面向对象程序设计上机练习二(函数模板)
#include <bits/stdc++.h>using namespace std;template <typename T>T Sort(T n){ T max = -123456; for(int i = 0; i < 4; i++) { if(n >= max) { max = n; }原创 2017-09-15 09:28:37 · 261 阅读 · 0 评论 -
1142-面向对象程序设计上机练习三(有默认参数的函数)
#include <bits/stdc++.h>using namespace std;int qaq(int x, int y, int z = 0){ int t = x; if(t < y) t = y; if(t < z) t = z; return t;}int main(){ int x,y,z; cin >> x >> y >> z;原创 2017-09-15 09:29:06 · 255 阅读 · 0 评论 -
1143-面向对象程序设计上机练习四(变量引用)
#include <bits/stdc++.h>using namespace std;void Sort(int &a, int &b){ int t; if(a > b) { t = a; a = b; b = t; }}int main(){ int a,b; cin >> a >> b;原创 2017-09-15 09:29:33 · 215 阅读 · 0 评论 -
2670-Point类的构造函数
#include <bits/stdc++.h>using namespace std;class Point{private: int x, y;public: Point() { x = 0; y = 0; ShowPoint(); } Point(int x, int y):Point() /*调用构原创 2017-09-29 00:30:04 · 149 阅读 · 0 评论 -
C+Windows句柄 实现贪吃蛇
#include <stdio.h>#include <conio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <Windows.h>void hideCursor() //隐藏光标{ HANDLE hOut = G...原创 2018-04-13 18:52:17 · 244 阅读 · 0 评论