
代码练习打卡
文章平均质量分 68
乔念嵩嵩子
这个作者很懒,什么都没留下…
展开
-
敲代码的第二十三天:模板与异常——分数类(版本一完整)(c++)
#include<iostream>#include<string.h>using namespace std;class denominator_zero {};template<class T>class score {private: T molecular; T denominator;...原创 2021-11-18 23:24:09 · 213 阅读 · 0 评论 -
敲代码的第二十三天:模板与异常——分数类(版本一完整)(c++)
#include<iostream>#include<string.h>using namespace std;class denominator_zero {};template<class T>class score {private: T molecular; T denominator;...原创 2021-11-18 23:23:02 · 220 阅读 · 0 评论 -
敲代码的第二十三天:模板分数上篇(c++)
#include<iostream>#include<string.h>using namespace std;class denominator_zero {};template<class T>class score {private: T molecular; T denominator;public: score() {} score(T x, T y); score add(score x); sco...原创 2021-11-17 23:32:36 · 583 阅读 · 0 评论 -
敲代码的第二十二天:创建简单学生类(c++)
#include<iostream>#include<fstream>#include<string>#include<vector>using namespace std;class Student { string name; float score;public: Student() {} Student(string n, float sc) { name = n; score...原创 2021-11-15 23:06:27 · 892 阅读 · 0 评论 -
敲代码的第二十天:职员信息类(c++)
#include<iostream>using namespace std;class Employee {protected: char Name[30]; char Num[5]; int Work_Age; double Total_Salary;public: virtual void Get_Message(); virtual void Pay() = 0 ; void Show_Message();};class...原创 2021-11-10 23:42:09 · 831 阅读 · 0 评论 -
敲代码的第十九天:利用继承和多态求正方体,圆柱体,球体的面积和体积(c++)
#include<iostream>using namespace std;class basic {public: virtual double superficial_area() = 0; virtual double volume() = 0; ~basic() {}};class cube :public basic{private: double length;public: cube(double a) :len...原创 2021-11-08 19:50:25 · 1096 阅读 · 3 评论 -
敲代码的第十八天:推箱子2.0(java)
package com.wangwang2;import javax.swing.*;import java.awt.*;import java.awt.event.KeyEvent;import java.awt.event.KeyListener;public class GameFrame extends JFrame { private JPanel panel = null; private JLabel box = null; private JLabel.原创 2021-11-07 20:26:07 · 176 阅读 · 0 评论 -
敲代码的第十七天:账户类第三版下完整版(c++)
#include<iostream>#include<string>using namespace std;class Bank {protected: const string id; string password; double balance;public: Bank(const string Id, string Password, double Balance) :id(Id) { password = Pass...原创 2021-10-30 23:10:19 · 103 阅读 · 0 评论 -
敲代码的第十六天:创建子类账户第三版(上)(c++)
#include<iostream>using namespace std;class Bank {protected: const string id; string password; double balance;public: Bank(const string Id, string Password, double Balance) :id(Id) { password = Password; balance = ...原创 2021-10-28 23:52:50 · 125 阅读 · 0 评论 -
敲代码的第十五天:复数的运算(类和对象)(c++)
#include<iostream>using namespace std;class Complex {private: double real, imag;public: Complex(double r = 0.0, double i = 0.0) { real = r; imag = i; } Complex operator +(Complex c); Complex operator -(Compl...原创 2021-10-27 21:45:57 · 93 阅读 · 0 评论 -
敲代码的第十四天:完整推箱子第一版第二遍(java)
package niansong1;import javax.swing.*;import java.awt.*;import java.awt.event.KeyEvent;import java.awt.event.KeyListener;import java.awt.font.ImageGraphicAttribute;public class TXZ { public static void main(String[] args){ JFrame gameF.原创 2021-10-24 18:03:38 · 1544 阅读 · 0 评论 -
敲代码的第十三天:引用基础(c++)
#include<iostream>using namespace std;//返回局部变量引用int& test01(){ int a=10; return a;}int& test02(){ static int a = 20; return a;}int main(){ //不能返回局部变量的引用 int &ref = test01(); cout<<"ref = "<&l...原创 2021-10-23 21:43:21 · 70 阅读 · 0 评论 -
敲代码的第十二天:推箱子基础完整版(java)
package com.wangwang1;import javax.swing.*;import java.awt.*;import java.awt.event.KeyEvent;import java.awt.event.KeyListener;public class TXZ1 { public static void main(String[] args) { //类名 对象名; JFrame gameFrame = new JFrame();.原创 2021-10-22 23:18:25 · 164 阅读 · 0 评论 -
敲代码的第十一天:推箱子练习(设置窗口,添加围墙及图片)(java)
package wangwang2;import javax.swing.*;import java.awt.*;import java.awt.font.ImageGraphicAttribute;public class TXZ2 { public static void main(String[] args){ JFrame gameFrame = new JFrame(); gameFrame.setTitle("推箱子"); ga.原创 2021-10-21 23:16:02 · 135 阅读 · 0 评论 -
敲代码的第十天:储蓄账户版本二(c++)
#include<iostream>#include<string>using namespace std;class BaseAccount{public: static long money; const long num;public: BaseAccount():num(888666) { cout<<"请输入六位银行账户:"; long num1; while(1) {cin>...原创 2021-10-20 23:24:06 · 134 阅读 · 0 评论 -
敲代码的第九天:推箱子----使人物移动(java)
接前篇for (int i = 1; i <= 10; i++) { panel.add(walls[index]); walls[index++].setBounds(0, i * 48, 48, 48); panel.add(walls[index]); walls[index++].setBounds(21 * 48, i * 48, 48, 48); } //添.原创 2021-10-19 22:06:40 · 291 阅读 · 0 评论 -
敲代码的第八天:构建储蓄账户类,用到继承性(c++)
#include <iostream>#include <string.h>using namespace std;class Account {private: int id; char name[20]; //字符数组 int money;public: Account(); Account(int id); Account(int id, char name[], int money); void in.原创 2021-10-18 22:15:35 · 218 阅读 · 0 评论 -
敲代码的第五天:不知名(c++)
#include<iostream>#include<cmath>using namespace std;int find(n){ int count = 0; long num=0,x = 0, y = 0; while(1){ num++; x = sqrt(num+100); y = sqrt(num+268); if(x*x==num+100&&y*y==num+26...原创 2021-10-13 21:53:58 · 64 阅读 · 0 评论 -
敲代码的第四天:计算二维平面图形面积(c++)
代码:#include <iostream>/* run this program using the console pauser or add your own getch, system("pause") or input loop */using namespace std;class TDshape{public: virtual void area() = 0; virtual void printName() = 0;};class Trian...原创 2021-10-12 20:56:16 · 267 阅读 · 0 评论 -
敲代码的第三天:创建时间类实现功能(c++)
题目要求:再加两个功能:正数计时和倒数计时#include<iostream>#include<windows.h>using namespace std;class Time {public:int hour;int minute;int sec;Time() {int hour=0;minute = 0;sec = 0;}Time(int h,int m, int s):hour(h),minute(m), s.原创 2021-10-11 22:16:07 · 249 阅读 · 0 评论 -
敲代码的第二天:构造函数特点及实例(c++)
1.构造函数的作用:由于类是一个抽象概念,不是实体,所以不可以在声明时对数据成员进行初始化,此时即需要构造函数来为对象的属性赋初值。2.构造函数的定义格式:类名(形参){ ...........};3.构造函数的特点(与普通方法的区别): a.方法名与类名相同:类名,构造方法名首字母大写,而普通方法中为小写; b.无返回值,也不用加void; c.构造函数对象创建时系统自动调用,而普通方法需要对象名.方法名调用。4....原创 2021-10-10 13:15:50 · 231 阅读 · 0 评论 -
敲代码的第一天:创建函数并调用求长方形面积(c++)
1.Rectangle.h#include<iostream>using namespace std;class Rectangle {private: int height; int width;public: Rectangle(); Rectangle(int height, int width); int getPerimeter(); int getPArea(); void print();};2.Rect原创 2021-09-26 21:31:40 · 1735 阅读 · 0 评论