要多写博客
今天上选修课,师兄提醒我们应该多写博客什么的,其实我觉得这挺不错的。
最近看C草草看得好头晕啊,一推的概念,要记的东西好多好多。
今晚看了《致我们终将逝去的青春》,感慨挺多的。
将来的我会是故事里的谁?
我谁都不是,我就是我。
我的青春,我做主。
虽然说青春就是用来怀念的,但是我还是要努力,不能让青春荒废了。
好了,洗澡吧。
-—2014/4/8 天下无双
-—于GDUT 西三543
专注游戏服务器开发
要拒绝无意义的游戏行为
不要花太多时间在无意义的娱乐游戏上。
可以玩游戏,但是不是单纯以玩家的角度去玩,要以一个开发者的角度去玩,要记住自己玩游戏的初衷。
try it!
do it !
from now on.
赶紧重回毕设模式
差不多花了四五天来完成自己邮箱服务器和web服务器及各种网站建设,真的是从无都有啊~~~~
之前很少搞网站设计,就高三到大学期间搞过Dreamweaver,学了点简单的html语法~~~
从想拥有一个自己的网站开始,到真正搞点东西出来,不容易啊~
这几天做的东西离毕设的东西有点远啦,赶紧重回毕设模式~
文章作者:coderguang email: royalchen@royalchen.com
博客链接:http://blog.royalchen.com
备注:自2015-03-25之后,如无特殊说明,文章均为coderguang原创,转载请注明出处,文章由coderguang保留所有权利。
日期:2015-03-26
该文章摘自于自有博客,写于2015-03.26。
输出一串字符中第一个只出现一次的字符不能使用whilefor循环
//这是昨晚uc笔试的最后一道算是算法题吧.
<pre code_snippet_id=”346769” snippet_file_name=”blog_20140515_3_1928683” name=”code” class=”cpp”>//goto的写好了,预约了教练去练车了,递归的晚上回来再写。
<pre code_snippet_id=”346769” snippet_file_name=”blog_20140515_5_893881” name=”code” class=”cpp”>//输出一串字符中第一个只出现一次的字符
//如输入为abaccdff 输出b
//不能使用库函数以及for/while循环
//其实一开始也想到用递归代替循环,但是后来想想好像goto也可以实现,
//而且觉得goto比较简单,然后就用了goto
//回来的时候感觉考官想考我们的不是goto,应该是想考我们的递归,我去,果断坑了
#include
#include
#include
using namespace std;
int goTo(const char *str)
{
int i=0,j=1;
int len=strlen(str);//获取长度
//不常用goto,都忘了格式了!
loop:
//当时忘记判断这一个了
if(i==j)//忘了判断不能自身比较了
{
if(i==len-1)//这个也忘记判断了,当这是最后一个字符而且与前面都不同时
{
cout<<str[i]<<endl;
return 0;
}
j++;
if(j==len)//如果str[i]已经和当前每一个都比较过了
{
i++;//比较下一个
if(i==len)//如果没有下一个
return 1;
}
goto loop;
}
//if(strcmp(str[i],str[j])!=0)//逐个比较,如果不相等
//strcmp() 忘了这个是比较字符串的了
if(str[i]==str[j])
{
i++;//比较下一个
j=0;//令j重置为0//怎么我当时好像改成了j=i+1;
if(i==len)//如果没有下一个
return 1;
goto loop;//否则继续比较
}
else
{
j++;
if(j==len)//如果str[i]已经和当前每一个都比较过了
{
//此时说明该字符只出现了一次
cout<<str[i]<<endl;
return 0;
}
else
goto loop;//否则继续下一次比较
}
}
int main()
{
char *s=”cceef”;
goTo(s);
cin.get();
return 0;
}
递归解法
//递归思想
//其实跟goto是一样的思想
//不过设多两个变量i,j用于指示要比较的字符和正在比较的字符传递给递归函数
#include
using std::cout;
using std::endl;
using std::strlen;
using std::cin;
#define ERROR ‘-1’//倘若没有任何一个匹配
char digui(const char *str,int i,int j)
{
int len=strlen(str);
if(i==j)//如果i=j,则不与自身比较
{
if(i==len-1)//但如果是i=j=len-1,说明最后一个只在最后出现了一次,输出
return str[i];
else//否则,跳过i=j,j++
{
j++;
digui(str,i,j);//进入下一次递归
}
}
else if(str[i]==str[j])//倘若一个字符出现两次
{
//cout<<”i=”<<i<<” “<<”j=”<<j<<” “<<(int*)(&str[i])<<” “<<(int*)(&str[j])<<endl;
i++;//进行下一个字符比较;
if(i==len)
{
cout<<”没有一个只出现一次的字符”<<endl;
return ERROR;
}
else
{
j=0;//重置j=0;
digui(str,i,j);
}
}
else//否则,移动j,继续比较,知道j=len;
{
j++;
if(j==len)//如果比较到了最后都不相等
{
//cout<<str[i]<<endl;
return str[i];
}
else//还没到最后
{
digui(str,i,j);
}
}
}
int main()
{
char *s=”cceet”;
cout<<digui(s,0,0);
cin.get();
return 0;
}
进制转换,用栈实现
今天看数据结构中的栈解决进制转换的问题,实现了一下。
linux下gdb调程序感觉还是会有一点麻烦啊,主要是不能一下子看到很多变量的值,要一个个地去p,好郁闷
代码如下:
stack.cpp
//用于实现栈的操作
#include
using namespace std;
//const int MAX=100;//栈最大长度值为100,用数组实现栈
//写成模板类是为了方便我以后使用
template
class mStack{
private:
enum {MAX=100};
T arr[MAX];
int Size;
int top;//用于指示栈顶位置
public:
mStack()//构建空栈
{
top=-1;//下标为-1则为空栈
Size=0;
}
bool isEmpty()
{
return top==-1;
}
bool isFull()
{
return top==MAX-1;
}
bool Push(T &item)
{
if(isFull())
{
cout<<”stack is full!”<<endl;
return false;
}
//++top;
//arr[++top]=item;
arr[++top]=item;//因为下标从-1开始,使用前+1
//cout<<”this “<<top<<” item push values is :”<<arr[top]<<endl;
Size++;
return true;
}
bool Pop(T &item)
{
if(isEmpty())
{
cout<<”stack is empty!”<<endl;
return false;
}
item=arr[top–];//因为下标从-1开始,top指向当前最后一个元素,使用后-1
//cout<<”this “<<top<<” item pop values is :”<<arr[top]<<endl;
Size–;
return true;
}
int size()
{
return Size;
}
};
translate.cpp
#include
#include “stack.cpp”
using namespace std;
//static const int MAXSIZE=100;//用于顺序存放转换进制之后的值
//由于进制转换的特点,可以先让余数入栈,然后再出栈来求得转换后的值,接口如下,
//如果想返回一个值,可以改变接口的规则
void translate(int target,int n)//target是要转换的值,n为转换为多少进制
{
mStack
int yushu;
//核心代码,余数入栈
while(target!=0)
{
yushu=target%n;
my.Push(yushu);
/*if(my.Push(yushu))
cout<<”push success!”<<endl;
else
cout<<”push error!”<<endl;*/
//cout<<”stack size=”<<my.size()<<endl;
target=target/n;
}
/*
if(target%n==0)//最后一个
{
yushu=target%n;
my.Push(yushu);//将最后一个target%n入栈
}*/
//outpue
cout<<”the “<<target<<” translate to “<<n<<” is:”<<endl;
while(!my.isEmpty())
{
int temp;
my.Pop(temp);
//if(my.Pop(temp))
//cout<<”pop success!”<<endl;
cout<<temp;
}
cout<<endl;
}
test.cpp
#include
#include “translate.cpp”
using namespace std;
int main()
{
int target;
int n;
cout<<”please input two numbers;first for target,second for n:”;
while(cin>>target>>n)
{
translate(target,n);
//cin.get();
}
return 0;
}
12个时间管理妙招,你学会了吗?
NLP导读:一天的时间永远是24个小时,高效率的人能把24小时变成48小时,而低效率的人却能把24小时变成12小时,如何有效的利用时间,请看一个在高盛工作的学姐总结的12个时间管理妙招吧。
在朋友当中,我被认为是效率使用时间的人,因为我爬山、拍照、读书、学习、考各种证书、各种聚会,还有一份不算清闲的工作。总有人好奇问:你是怎么同时办成这么多事情的,你不睡觉吗?或者你丫到底上班吗?NLP实用心理学专家黄启团先生说过,习惯决定一个人的未来。养成一个良好的时间管理习惯,直接决定了你的未来。
我的答案是,时间就是海绵里的水,也是平胸的乳沟。能做更多的事情,并不一定是比别人有更多的空闲时间,而是比别人使用时间更有效率。关于使用时间的个人建议:
1、高度的集中力。任何事情,没有专注的能力效率无从谈起,因此要培养迅速将注意力集中到一件事情上的能力,而且抗干扰能力要强。
2、善于利用碎片时间。人一天的碎片时间是很多的,对于上班族来说尤其如此,比如等汽车、等火车、等飞机、等UFO的时候,比如路途中没有美女搭讪的时候,不要小看碎片时间,积少成多是很可观的,完全可以用这些时间看看书、思考一些问题。
3、有deadline。工作中学习中的deadline(最后期限)除了外界施加的,个人也应当对自己提出要求,并且把这个deadline作为一个强制性的标准,必须按时完成,取信于人很重要,取信于自己也很重要,这能让你尊重自己的计划和安排。
4、每天有一个时间的计划。事情的轻重缓急按顺序排好,首先完成重要且紧急的,其次是重要但不紧急的,最后才是其他事情。另外不要把时间浪费在无意义的事情上面。
5、休闲也是合理使用时间的一部分。不要长时间闲散,但是应当把休闲作为生活中的一部分。
6、掌握良好的做事方法。工欲善其事必先利其器,好的方法可以提高效率。在做事情的时候应当迅速学习和总结经验,选择最优的方法。
7、少看电视。电视节目可以作为娱乐,但是作为学习方式不合适。
8、形成自己的工作/学习节奏。在需要相互协调、协作的事情上,和团体保持一致。在个人的领域中,应当根据自己的能力形成符合自己习惯和能力的学习/工作节奏。对于学生来说,老师讲课的节奏并不快,完全可以形成自学+疑难找老师的模式。
9、一鼓作气很重要。很多事情往往都是刚开始气势高昂,决心满满,但是做到后来越来越拖沓。与其如此,不如一鼓作气完成,尤其对于那些意志力不强的人。
10、培养自己的意志力。给自己制定一个30天计划,在这30天内每天一定完成某件事情,比如按时起床、或者跑10公里等。
11、经常体育锻炼。体育锻炼可以培养意志力,同时让你的头脑变得清醒和兴奋,比打鸡血好用。
12、对未来有想法。目标如同灯塔,人生中大方向上的努力和主要时间都是往这个方向。不管有什么目标,有目标并且努力实践的人会过的比没有目标的人充实,也会更加懂得时间的可贵。
NLP导读:一天的时间永远是24个小时,高效率的人能把24小时变成48小时,而低效率的人却能把24小时变成12小时,如何有效的利用时间,请看一个在高盛工作的学姐总结的12个时间管理妙招吧。
在朋友当中,我被认为是效率使用时间的人,因为我爬山、拍照、读书、学习、考各种证书、各种聚会,还有一份不算清闲的工作。总有人好奇问:你是怎么同时办成这么多事情的,你不睡觉吗?或者你丫到底上班吗?NLP实用心理学专家黄启团先生说过,习惯决定一个人的未来。养成一个良好的时间管理习惯,直接决定了你的未来。
我的答案是,时间就是海绵里的水,也是平胸的乳沟。能做更多的事情,并不一定是比别人有更多的空闲时间,而是比别人使用时间更有效率。关于使用时间的个人建议:
1、高度的集中力。任何事情,没有专注的能力效率无从谈起,因此要培养迅速将注意力集中到一件事情上的能力,而且抗干扰能力要强。
2、善于利用碎片时间。人一天的碎片时间是很多的,对于上班族来说尤其如此,比如等汽车、等火车、等飞机、等UFO的时候,比如路途中没有美女搭讪的时候,不要小看碎片时间,积少成多是很可观的,完全可以用这些时间看看书、思考一些问题。
3、有deadline。工作中学习中的deadline(最后期限)除了外界施加的,个人也应当对自己提出要求,并且把这个deadline作为一个强制性的标准,必须按时完成,取信于人很重要,取信于自己也很重要,这能让你尊重自己的计划和安排。
4、每天有一个时间的计划。事情的轻重缓急按顺序排好,首先完成重要且紧急的,其次是重要但不紧急的,最后才是其他事情。另外不要把时间浪费在无意义的事情上面。
5、休闲也是合理使用时间的一部分。不要长时间闲散,但是应当把休闲作为生活中的一部分。
6、掌握良好的做事方法。工欲善其事必先利其器,好的方法可以提高效率。在做事情的时候应当迅速学习和总结经验,选择最优的方法。
7、少看电视。电视节目可以作为娱乐,但是作为学习方式不合适。
8、形成自己的工作/学习节奏。在需要相互协调、协作的事情上,和团体保持一致。在个人的领域中,应当根据自己的能力形成符合自己习惯和能力的学习/工作节奏。对于学生来说,老师讲课的节奏并不快,完全可以形成自学+疑难找老师的模式。
9、一鼓作气很重要。很多事情往往都是刚开始气势高昂,决心满满,但是做到后来越来越拖沓。与其如此,不如一鼓作气完成,尤其对于那些意志力不强的人。
10、培养自己的意志力。给自己制定一个30天计划,在这30天内每天一定完成某件事情,比如按时起床、或者跑10公里等。
11、经常体育锻炼。体育锻炼可以培养意志力,同时让你的头脑变得清醒和兴奋,比打鸡血好用。
12、对未来有想法。目标如同灯塔,人生中大方向上的努力和主要时间都是往这个方向。不管有什么目标,有目标并且努力实践的人会过的比没有目标的人充实,也会更加懂得时间的可贵。
5.1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace c5._1
{
class MyMath{
public const double PI = 3.1415926;
public static double Perimeter(double r)
{
return 2 \* PI \* r;
}
public static double Area(double r)
{
return PI \* r \* r;
}
public static double Volume(double r)
{
double v = 4 \* PI \* Math.Pow(r, 3) / 3;
return v;
}
}
class Program
{
static void Main(string\[\] args)
{
Console.Write("请输入半径:");
double r = double.Parse(Console.ReadLine());
Console.WriteLine("圆的周长={0}",MyMath.Perimeter(r));
Console.WriteLine("圆的面积={0}",MyMath.Area(r));
Console.WriteLine("圆的体积={0}",MyMath.Volume(r));
Console.ReadKey();
}
}
}
5.2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace c5._2
{
public class TemperatureCelsius
{
protected double degree;
public TemperatureCelsius(double d)
{
this.degree = d;
}
public double ToFahrenheit()
{
return (degree * 9 / 5)+32;
}
}
class Program
{
static void Main(string\[\] args)
{
Console.Write("请输入摄氏温度:");
double d = Double.Parse(Console.ReadLine());
TemperatureCelsius t = new TemperatureCelsius(d);
Console.WriteLine("摄氏温度={0},华氏温度={1}",d,t.ToFahrenheit());
Console.ReadKey();
}
}
}
5.3
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace c5._3
{
public class Person
{
public string name;
public uint age;
public Person(string name, uint age)
{
this.name = name;
this.age = age;
}
public virtual void GetInfo()
{
Console.WriteLine(“Name:{0}”, name);
Console.WriteLine(“Age:{0}”, age);
}
}
public class Teacher:Person
{
public uint TeacherID;
public Teacher(string name, uint age, uint id)
: base(name, age)
{
this.TeacherID = id;
}
public override void GetInfo()
{
base.GetInfo();
Console.WriteLine("TeacherID:{0}", TeacherID);
}
}
class Program
{
static void Main(string\[\] args)
{
Teacher t = new Teacher("陈世光", 15, 100);
t.GetInfo();
Console.ReadKey();
}
}
}
5.4
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace c5._4
{
public abstract class Shape {
protected string name;
public Shape(string name)
{
this.name = name;
}
public abstract void Show();
public abstract double Area();
}
public class Rectangle : Shape
{
protected double weight;
protected double height;
public Rectangle(string name, double w, double h)
: base(name)
{
this.weight = w;
this.height = h;
}
public override void Show()
{
Console.WriteLine("Rectangle:{0}, Area:{1}", name, Area());
}
public override double Area()
{
return weight \* height;
}
}
public class Circle : Shape
{
protected double r;
const double PI = 3.1415929;
public Circle(string n, double r)
: base(n)
{
this.r = r;
}
public override void Show()
{
Console.WriteLine("Circle:{0}, Area:{1}", name, Area());
}
public override double Area()
{
return PI \* r \* r;
//return base.Area();
}
}
class Program
{
static void Main(string\[\] args)
{
Shape\[\] s={new Rectangle("矩形",10,2.5),new Circle("圆",4)};
foreach(Shape e in s)
{
e.Show();
}
Console.ReadKey();
}
}
}
5.5
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace c5._5
{
public class Complex
{
protected int real;//shibu
protected int imaginary;//虚部
public Complex(int r, int i)
{
this.real = r;
this.imaginary = i;
}
public static Complex operator +(Complex c1, Complex c2)//必须定义为static
{
return new Complex(c1.real + c2.real, c1.imaginary + c2.imaginary);
}
public static Complex operator -(Complex c1, Complex c2)
{
return new Complex(c1.real - c2.real, c1.imaginary - c2.imaginary);
}
public static Complex operator *(Complex c1, Complex c2)
{
return new Complex(c1.real * c2.real - c1.imaginary * c2.imaginary,
c1.real * c2.imaginary + c1.imaginary * c2.real);
}
public override string ToString()
{
return (String.Format(“{0}+{1}i”, real, imaginary));
//return base.ToString();
}
}
class Program
{
static void Main(string\[\] args)
{
Complex c1 = new Complex(4, 5);
Complex c2 = new Complex(3, 2);
Console.WriteLine("第一个复数:{0}", c1.ToString());
Console.WriteLine("第二个复数:{0}", c2.ToString());
Console.WriteLine("两个复数之和:{0}", (c1+c2).ToString());
Console.WriteLine("两个复数之差:{0}", (c1 - c2).ToString());
Console.WriteLine("两个复数之积:{0}", (c1 \* c2).ToString());
Console.ReadKey();
}
}
}
5.6
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace c5._6
{
public interface ICDPlayer
{
void Play();
void Stop();
void PreviousTrack();
void NextTrack();
void Off();
int CurrentTrack
{
get;
}
}
public class CDPlayer : ICDPlayer
{
private int currentTrack = 0;
public void Play()
{
Console.WriteLine("启动Rhythmbox...");
}
public void Stop()
{
Console.WriteLine("暂停Rhythmbox...");
}
public void PreviousTrack()
{
Console.WriteLine("上一首");
if (currentTrack >= 1)
currentTrack--;
}
public void NextTrack()
{
Console.WriteLine("下一首...");
//if(currentTrack)
currentTrack++;
}
public void Off()
{
Console.WriteLine("OFF!");
}
public int CurrentTrack {//好奇葩的方法,没有参数列表的??
get {
return currentTrack;
}
}
}
class Program
{
static void Main(string\[\] args)
{
CDPlayer cd = new CDPlayer();
cd.Play();
Console.WriteLine("CD.currentTrack={0}", cd.CurrentTrack);
cd.NextTrack();
cd.NextTrack();
Console.WriteLine("CD.currentTrack={0}", cd.CurrentTrack);
cd.PreviousTrack();
Console.WriteLine("CD.currentTrack={0}", cd.CurrentTrack);
cd.Stop();
cd.Off();
Console.ReadKey();
}
}
}
5.7
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;//for ArrayList
namespace c5._7
{
//①:声明提供事件数据的类,作为事件方法的参数
//即传递给事件的参数
public class NameListEventArgs : EventArgs
{
public string Name { get; set; }
public int Count{ get; set; }
public NameListEventArgs(string n, int c)//:Name(namespace),Count(c)
//实践证明不能用C++的默认初始化方法
{
Name = n;
Count = c;
}
}
//②:声明事件处理委托
public delegate void NameListEventHadndler(object source,NameListEventArgs args);
//③:声明引发事件的类,事件产生类
public class NameList
{
ArrayList list;
//④:在事件产生类中声明事件
public event NameListEventHadndler nameListEvent;//声明事件
public NameList()
{
list = new ArrayList();
}
public void Add(string name)
{
list.Add(name);
//⑤:产生事件
/*
if (nameListEvent != null)
{
nameListEvent(this, new NameListEventArgs(name, list.Count));
}*/
nameListEvent(this, new NameListEventArgs(name, list.Count));
}
}
//⑥:声明处理事件的类
public class EventDemo
{
//声明事件处理方法,跟委托声明中参数要一样
public static void Method1(object source, NameListEventArgs args)
{
Console.WriteLine(“列表中增加了项目:{0}” , args.Name);
}
public static void Method2(object source, NameListEventArgs args)
{
Console.WriteLine(“列表中的数目:{0}” , args.Count);
}
static void Main(string\[\] args)
{
NameList n1 = new NameList();
NameListEventHadndler p = new NameListEventHadndler(EventDemo.Method1);
//n1.nameListEvent+=new NameListEventHadndler(EventDemo.Method1);
//⑦:订阅事件
n1.nameListEvent += p;
n1.nameListEvent+=new NameListEventHadndler(EventDemo.Method2);
n1.Add("张三");
n1.Add("311006121");
n1.nameListEvent -= p;
n1.Add("陈某某");
Console.ReadKey();
}
}
}
—————————————————————————————————————————————————— //写的错误或者不好的地方请多多指导,可以在下面留言或者给我发邮件,指出我的错误以及不足,以便我修改,更好的分享给大家,谢谢。 转载请注明出处:https://www.royalchen.com/ author:royalchen Email:royalchen@royalchen.com ———————————————————————————————————————————————————
缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是yilia-plus根目录)执行以下命令:
npm i hexo-generator-json-content --save
3、在根目录_config.yml里添加配置:
jsonContent: meta: false pages: false posts: title: true date: true path: true text: false raw: false content: false slug: false updated: false comments: false link: false permalink: false excerpt: false categories: false tags: true