Skip to content

Instantly share code, notes, and snippets.

View techlarry's full-sized avatar

Zhenhua Wang techlarry

View GitHub Profile
#include <iostream>
using namespace std;
class CArray {
int size; //数组元素的个数
int *ptr; //指向动态分配的数组
public:
CArray(int s = 0);
描述
魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市。
红司令部,City 1,City 2,……,City n,蓝司令部
两军的司令部都会制造武士。武士一共有 dragon 、ninja、iceman、lion、wolf 五种。每种武士都有编号、生命值、攻击力这三种属性。
双方的武士编号都是从1开始计算。红方制造出来的第n个武士,编号就是n。同样,蓝方制造出来的第n个武士,编号也是n。
描述
在一个学生信息处理程序中,要求实现一个代表学生的类,并且所有成员变量都应该是私有的。
输入
姓名,年龄,学号,第一学年平均成绩,第二学年平均成绩,第三学年平均成绩,第四学年平均成绩。
其中姓名、学号为字符串,不含空格和逗号;年龄为正整数;成绩为非负整数。
#include <iostream>
using namespace std;
int main()
{
char a;
cin >> a;
for(int i =1; i<=3;i++){
for (int j=1; j<4-i;j++)
cout << " ";
#include <iostream>
using namespace std;
int main()
{
int a;
cin >> a;
cout << (char) a;
}
@techlarry
techlarry / 代码
Created October 30, 2017 08:33
`Greatest Common Divisor` (最大公约数) GCD(m, n) is: if m modulo n equals 0 then n; else GCD(n, m mod n);
#include<iostream>
#include<cstdlib>
using namespace std;
int gcd(int a, int b)
{
// swap a and b
if (a<b)
@techlarry
techlarry / Factorial.cpp
Created October 30, 2017 07:46
compute factorial using recursive in C++
// A simple recursive function has two main parts: the base-case part, where it computes a vaue and terminates,
// and the recursive part, where it calls itself.
#include <iostream>
//Recursive factorial function
//
//#include<iostream>
@techlarry
techlarry / 0_reuse_code.js
Created June 8, 2017 08:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Python 高级

模块重新导入

模块导入: import xxx, from xxx import xxxx 增加路径

import sys
sys.path.append(path)