自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(38)
  • 资源 (2)
  • 收藏
  • 关注

转载 Merge sort array

//从后往前扫描,不用另开数组class Solution {public: void merge(int A[], int m, int B[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function int index

2014-07-25 18:50:31 346

原创 Merge Intervals 练习vector

bool cmp(const Interval &m,const Interval &n) { return m.start < n.start; }class Solution {public: vector merge(vector &intervals) { vector result; if (

2014-07-24 21:58:17 393

原创 atoi 自己实现 leecode

#include #include #include #include #include class Solution {public: int atoi(const char *str) { long long total = 0; while (isspace(*str)) str++; int c =

2014-07-24 00:47:34 378

转载 最长未重复子串

class Solution {public: int lengthOfLongestSubstring(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function int locs[256];//保存字符上一次出现的位置

2014-07-23 13:46:28 297

原创 简单文件操作 linux

#include #include #include #include using namespace std;class fileop{public: void filewrite(char *a,const char *path); ~fileop(); void fileread(char *path);private: FILE * fp; char buf[10

2014-07-22 13:21:41 368

原创 vector 实现文本字符串大小写转换 3.14

#include#include#include#includeusing namespace std;int main(){ vector word; string a; while(cin>>a) { int len=a.length(); for(int i=0;i<len;i++) {

2014-01-22 14:52:21 778

原创 nyoj128 前缀表达式计算

/*前缀表达式计算思想 从所给的数里从后往前算 遇到第一个符号位离它最近的俩位数的运算符 直接运算*/#include #include #include int isspa(char a);int isop(char a);double popnum(double a[]);double expcal(double a,double b,char c);void pus

2013-12-02 16:42:49 570

原创 中缀表达式变后缀表达式 nyoj467

/*中缀式变后缀式思想 运算符等级 '*''/'>'+''-'>'('>')' 如果运算符栈为空,运算符入栈, 如果运算符不为‘)’,且栈顶运算符不为'(' 则比较运算符优先级,若栈顶优先级更高,则将栈顶元素移至数字栈,否则符号入栈*/#include #include #include int isop(char a);//判断是否为符号void rechan(char

2013-12-02 11:05:40 413

转载 关于中缀表达式和逆波兰表达式(终结篇)

表达式求值清晰思想关于中缀表达式和逆波兰表达式(终结篇)逆波兰表达式被广泛应用于编译原理中,但是近来在研究计算一元一次方程的时候发现通过逆波兰算法计算一元一次方程会更简单,原因是逆波兰表达式有一个其他的算法不能比拟的优点–拆括号(关于一元一次方程的算法程序,我会在以后陆续登载)。 标准的表达式如"A+B",在数学上学名叫中缀表达式(Infix N

2013-12-02 01:14:12 567

原创 表达式求值 nyoj35

/* 表达式思想 运算符优先级*/#include #include #include double expcal(double a,double b,char c);char popop(char b[]);//运算符出栈double popnum(double b[]);//数字出栈double getnum(double b[]);//取栈顶数字double popn

2013-12-02 01:12:27 401

转载 NOYJ 63小猴子

小猴子下落时间限制:3000 ms  |  内存限制:65535 KB难度:3 描述有一颗二叉树,最大深度为D,且所有叶子的深度都相同。所有结点从左到右从上到下的编号为1,2,3,·····,2的D次方减1。在结点1处放一个小猴子,它会往下跑。每个内结点上都有一个开关,初始全部关闭,当每次有小猴子跑到一个开关上时,它的状态都会改变,当到达一个内结点时,如果开关关

2013-11-23 11:20:42 960

原创 NYOJ 2 括号匹配问题

思路:最先找到的‘]’或者‘)’它的前一个符号必定是匹配的括号,从最深入的括号开始不断往外查找,#include #include int main(){ int Ncase; char a[10001]; int len; int i,j; scanf("%d",&Ncase); while(Ncase--) { scanf("%s",a); len=st

2013-11-10 23:24:51 359

转载 第一章 系统环境 1.5习题 1.6上机实训

(1)linux 系统由哪几部分组成,具有哪些功能答:四个部分内容组成,系统内核,shell,文件系统和实用工具。内核对外提供系统调用的接口,其余三个部分通过访问系统调用实现各自功能。上机实训(1)查看系统内核uname -a或者cat /proc/version(2)centos对操作系统进行更新yum update

2013-09-14 15:23:16 568

原创 沉痛的教训

函数调用时,给形参分配单独的内存空间,实参把值传递给形参,实际是把实参的值存放在形参的内存空间,形参的值是实参值的备份。所以形参交换并不会达到交换实参的目的。#include #include void fun();int main(){ int a[100],*b;// b=(int)malloc(sizeof(int)); fun(a,&b); printf("%d%d",a

2013-07-06 19:43:10 538

转载 typedef

定义新的类型名来代替已有的类型名typedef 原类型名  新类型名;typedef int Countype  Countype m 等价于int mtypedef struct{         intnum;         char*name;         charsex[2];         intage;         floatscor

2013-07-02 10:59:46 380

转载 结构

结构:一种构造的数据类型声明结构一般形式:struct 结构类型名{         成员表};struct StudentType{         intnum;         char*name;         charsex[3];         floatscore;};结构类型变量的定义1:先声明再定义struct 结构

2013-07-02 10:59:17 372

转载 联合

一个联合类型所有成员共享空间联合类型变量长度等于各成员最长的长度每次只能赋一种值,新值覆盖旧值。所以应用于选择。声明格式union 联合类型名{         成员表}; 联合变量的定义1:先声明后定义union classorofiicetype{         intclass;         charoffice[10];};

2013-07-02 10:58:41 460

转载 指针的指针

#include int main(){ char *name[]={"china","beijing","longmai"}; char **p_name; int i; p_name=name; for (i=0;i<3;i++) { printf("%c\n",**(p_name+i)); printf("%s\n",*(p_name+i)); } r

2013-07-01 15:41:41 351

转载 register

static 函数内部函数和外部函数当一个源程序由多个源文件组成时,C语言根据函数能否被其它源文件中的函数调用,将函数分为内部函数和外部函数。内部函数(又称静态函数)如果在一个源文件中定义的函数,只能被本文件中的函数调用,而不能被同一程序其它文件中的函数调用,这种函数称为内部函数。定义一个内部函数,只需在函数类型前再加一个“static”关键字即可,如下所示

2013-06-27 23:09:16 453

原创 冒泡排序

#include void buble(int a[],int i);int main(){ int a[100],i,j; i=1; while(scanf("%d",&a[i++])!=EOF) { ; } i-=2; buble(a,i); for (j=1;j<=i;j++) { printf("%d\t",a[j]); } return 0;}vo

2013-06-26 22:21:38 335

原创 二分查找

#include #include void insertsort(int a[],int i);void BinarySearch(int x,int f,int l,int a[]);int main(){ int a[100],x; int i=1; printf("输入数据"); while(scanf("%d",&a[i++])!=EOF) { ; } i-=

2013-06-26 22:00:56 342

转载 小写字母转大写字母

#include #include int ToUpper(int c);int main(){ char str[81]; int i=0; puts("input a string"); while (strcmp(gets(str),"quit")) /* while循环里只要条件不为0,就可以继续循环 一般形式:strcmp(字符串1,字符串2)说明:

2013-06-26 19:20:28 405

转载 将整形数据转换为反转数字字符串输出

#include void ItoaRevers(long l,char str[]);int main(){ long l1; char aChar[81]; int i=0; puts("please input a interger:"); scanf("%ld",&l1);//ld 长整型 while(l1!=0) { ItoaRevers(l1,aChar);

2013-06-26 19:10:26 551

转载 Strcat链接俩字符串

#include void StrCat(char target[],const char source[]);int main(){ char cTarget[80]="hello"; char cSource[40]="world"; StrCat(cTarget,cSource); printf("%s\n",cTarget);}void StrCat(char targe

2013-06-25 22:53:13 371

转载 用*代替数字

#include #include void HideCiper(char t[],char s[]);int main(){ char s2[81]=""; char t2[81]=""; puts("input ciper"); gets(s2); while (strlen(s2)) { HideCiper(t2,s2); printf("%s\n",t2);

2013-06-25 22:43:11 759

原创 判断闰年平年

#include int main(){ int year; puts("input a year:"); scanf("%d",&year); while (year!=0) { if((year%4==0&&year%100!=0)||(year%400==0)) { printf("%d is a leap year\n",year); } else

2013-06-25 22:27:17 490

原创 变量小结。

空白符:空格符,制表符,换行符变量名命名规则:1:变量名字只能由字母和数字组成且第一个字符必须是字母(下划线也算字符)                               2:系统库函数经常使用下划线作第一个变量名字,所以尽量不要使用下划线作第一个元素  变量名区分大小写 标识符: 变量名 ,函数名,宏名,语句标号 浮点型常量自动处理为double型。一个字节大

2013-06-25 21:03:22 421

原创 自定义字符串长度计算Strlen()

#include int Strlen(char s[]);int main(){ char cArry[81]; int length=80; while (length>0) { gets(cArry); length=Strlen(cArry); printf("%d\n",length); } return 0;}int Strlen(char s[])

2013-06-25 11:47:57 697

原创 统计输入最大行,并打印

#include int Getline(char nowline[]);void Strcpy(char to[],char from[]);int main(){ int length,maxlen; char longgest[10000]; char nowline[10000]; maxlen=0; while ((length=Getline(nowline))>0)

2013-06-24 22:37:08 470

原创 计算X的Y次方

#include int Pow(int x,int y);int main(){ int x, y; scanf("%d%d",&x,&y); printf("%d",Pow(x,y)); return 0;}int Pow(int x,int y){ int i,p; p=1; for(i=1;i<=y;i++) { p=p*x; } return p;}

2013-06-24 18:18:47 1899

转载 C语言main函数返回值问题

C语言之Main函数返回值问题分析很多人甚至市面上的一些书籍,都使用了void main( ) ,其实这是错误的。C/C++ 中从来没有定义过void main( )。C++ 之父 Bjarne Stroustrup 在他的主页上的 FAQ 中明确地写着 The definition void main( ) { /* ... */ }is not and neve

2013-06-24 18:04:56 762

原创 函数计算N的阶乘

#include int Factorial(int n);int main(){ int n; scanf("%d",&n); printf("%d",Factorial(n)); return 0;}int Factorial(int n){ int result,i; result=1; for (i=1;i<=n;i++) { result=result*i

2013-06-24 17:52:31 999

原创 键盘输入个数,行,单词计数

#include int main(){ int lcount,rcount,wcount,ch; lcount=rcount=wcount=0; while ((ch=getchar())!=EOF) { lcount++; if (ch=='\n'||ch==' '||ch=='\t') { ++wcount; if (ch=='\n') {

2013-06-24 01:42:03 586

原创 单词计数

#include int main(){ int wcount,ch; wcount=0; while ((ch=getchar())!=EOF) { if (ch==' '||ch=='\n'||ch=='\t') { ++wcount; } } printf("%d",wcount); return 0;}//空格或者‘\n’或者'\t'等价于单词个数

2013-06-24 01:32:07 400

原创 行计数

#include int main(){ int rcount=0; int ch; while ((ch=getchar())!=EOF) { if (ch=='\n') { ++rcount; } } printf("%d",rcount); return 0;}//统计‘\n’的次数等价于统计行数

2013-06-24 01:23:56 385

原创 统计键盘输入个数

#include int main(){ intlcount; lcount=0; while(getchar()!=EOF) { lcount++; } printf("%d",lcount); return0;}//回车空格

2013-06-24 01:16:35 488

原创 C 语言putchar和getchar()

#include int main(){ int ch; while ((ch=getchar())!=EOF) { putchar(ch); } return 0;}// 函数原型 //int getchar(void);//int putchar(int ch);//注意char型一般默认是0-255所以不能吧ch定义成char型否则有可能接受不到-1,EOF是系统用

2013-06-22 23:08:50 922

原创 C语言基本数据类型int float double

#include int main(){ int a=10; short b=11; long c=12; float d=13; double e=14; printf("%d\t%d\t%d\t%lf\t%lf",a,b,c,d,e); return 0;}结论:float和double型默认都是输出小数点后六位。

2013-06-22 23:00:26 969 1

跟我一起写Makefile_by_chenhao

makefile的学习感觉还不错,挺具体详细的一个关于makefile的学习

2013-10-10

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除