刘华世的官方博客

10 2012 档案

摘要:int array[5] = {1,2,3,4,5}; //指定下标长度并初始化所有元素.int array[5] = {1,2,3}; //指定下标长度并初始化部分元素. 1,2,3,0,0int array[] = {1,2,3,4,5}; //不指定下标长度并初始化所有元素.#include "stdafx.h"#include "iostream.h"#include "string.h"int main(int argc, char* argv[]){ char *array[3]; array[1] = new char[ 阅读全文
posted @ 2012-10-31 23:36 pythonschool 阅读(155) 评论(0) 推荐(0) 编辑
摘要:猴子吃桃问题:猴子第一天摘下若干个桃子,当即吃了一半,还不过瘾,又多吃了一个;第二天早上又将剩下的桃子吃掉一半,又多吃了一个;以后每天早上都吃掉前一天剩下的一半零一个。到第五天早上想再吃时,发现只剩下一个桃子了。试编写程序,求第一天共摘了多少?#include <stdio.h>#include <conio.h>#include <string.h>int GetSum(int day, int sum){ sum = (sum+1)*2; if(day==1) return sum; else GetSum(day-1, sum);}int m... 阅读全文
posted @ 2012-10-30 21:47 pythonschool 阅读(251) 评论(0) 推荐(0) 编辑
摘要:在登录一些网站或者游戏时, 都需要注册用户名。在注册时,是不可以注册已存在的用户名的。#include <stdio.h>#include <conio.h>#include <string.h>int main(int argc, char * argv[]){ char name[20], user[] = "pythonschool"; int sex; printf("请输入用户名:\n"); scanf("%s", name); char * str = (strcmp(name, use 阅读全文
posted @ 2012-10-29 23:05 pythonschool 阅读(116) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h>#include <conio.h> int main(int argc, char * argv[]){ char ch; int letters = 0, space = 0, digit = 0, others = 0; printf("请输入一组字符串:\n"); while((ch=getchar())!='\n') { if(ch>'a' && ch < 'z' || ch >'A' && 阅读全文
posted @ 2012-10-29 22:58 pythonschool 阅读(483) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h>#include <conio.h>int palind2(char str[], int k, int i){ int j = 0; for(j=0;j<=k;j++) { if(str[j]!=str[i--]) return 0; } return 1;}int palind(char str[], int k, int i){ if(str[k]==str[i-k]&&k==0) return 1; else if(str[k]==str[i-k]) ... 阅读全文
posted @ 2012-10-29 22:47 pythonschool 阅读(495) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h>#include <conio.h>int main(int argc, char * argv[]){ float stu1, stu2, stu3; double average; printf("请输入3个学生的语文成绩\n"); scanf("%f,%f,%f", &stu1, &stu2, &stu3); average = (stu1+stu2+stu3)/3.0; printf("这三个学生的平均成绩是:%6.2f\n", average 阅读全文
posted @ 2012-10-29 22:17 pythonschool 阅读(483) 评论(0) 推荐(0) 编辑
摘要:对于C++应用程序来说,数据主要有两种存储方式,一种是栈存储方式,一种是堆存储方式。栈存储通常用于存储战友用空间小、生命周期短的数据。如:局部变量和函数参数。栈存储-->>局部变量和函数参数-->>空间小,生命周期短堆存储-->>全局变量和静态变量-->>空间大,生命周期长::用户可以使用new运算符在堆中开辟一个空间,使变量存储在堆中.int *pData = new int; //定义一个整形指针,使用new运算符在堆中开辟空间*pData = 100; //为指针在堆中的数据赋值......delete pData; //释放pData在堆 阅读全文
posted @ 2012-10-29 21:51 pythonschool 阅读(815) 评论(0) 推荐(0) 编辑
摘要:#include "stdafx.h"#include "iostream.h"#include <math.h>#include <conio.h>#include <stdlib.h>//writeby:lhsbqb//http://www.pythonschool.comint main(int argc, char* argv[]){ double y; int x, m; //设置控制台窗口大小为120列(需要引入<stdlib.h>) system("mode 120"); 阅读全文
posted @ 2012-10-29 17:11 pythonschool 阅读(485) 评论(0) 推荐(0) 编辑
摘要:#include "stdafx.h"#include "iostream.h"const int CHAR_LEN = 128; //定义一个常量struct Student //定义一个结构体{ char szName[CHAR_LEN]; //姓名 int nAge; //年龄 char szSex[CHAR_LEN]; //性别 char szAddress[CHAR_LEN]; //地址};int main(int argc, char* argv[]){ Student mystu; //定义一个结构体对象 mystu.nAge = 15; 阅读全文
posted @ 2012-10-29 14:29 pythonschool 阅读(346) 评论(0) 推荐(0) 编辑
摘要:import urllib2import urllibimport reimport sqlite3print 'Create table test'db = sqlite3.connect('test.db')db.row_factory = sqlite3.Rowdb.text_factory = strdb.execute('drop table if exists test')db.execute('create table test (title text, name text)')for j in range(14): 阅读全文
posted @ 2012-10-29 11:25 pythonschool 阅读(673) 评论(0) 推荐(0) 编辑
摘要:C++标准库中的<sstream>提供了比ANSI C的<stdio.h>更高级的一些功能,即单纯性、类型安全和可扩展性。在本文中,我将展示怎样使用这些库来实现安全和自动的类型转换。为什么要学习如果你已习惯了<stdio.h>风格的转换,也许你首先会问:为什么要花额外的精力来学习基于<sstream>的类型转换呢?也许对下面一个简单的例子的回顾能够说服你。假设你想用sprintf()函数将一个变量从int类型转换到字符串类型。为了正确地完成这个任务,你必须确保证目标缓冲区有足够大空间以容纳转换完的字符串。此外,还必须使用正确的格式化符。如果使用了 阅读全文
posted @ 2012-10-29 11:22 pythonschool 阅读(1004) 评论(0) 推荐(0) 编辑
摘要:////////////////////////////////////////////////////////////////// File: getfileversion.cpp// Description: 获取EXE文件的属性详细信息// Created: 2012-10-18// Author: lhsbqb/////////////////////////////////////////////////////////////////*The following code shows how to get FILEINFO value from resource file.Thes 阅读全文
posted @ 2012-10-18 17:40 pythonschool 阅读(1766) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h>#include <stdlib.h>main(){ FILE *fp; int num=0,i; char c,str1[100]; printf("input string endwith enter:\n"); gets(str1); fp=fopen("lhsbqb.txt","w"); if(fp==NULL){printf("File open faild!");exit(0);} for(i=0;str1[i]!='\0';i 阅读全文
posted @ 2012-10-18 12:53 pythonschool 阅读(418) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h>#include <stdlib.h>main(){ FILE *fp; char c; fp=fopen("lhsbqb.txt","w"); if(fp==NULL){printf("file open faild!");exit(0);} for(c='a';c<='z';c++) { fputc(c,fp); } fclose(fp); printf("字每添加完成"); getchar();}http://w 阅读全文
posted @ 2012-10-18 12:51 pythonschool 阅读(241) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h>char *fdl(char *str){ char *q=NULL,*p;/*q就是所找字符的指针,找之前其值为NULL */ for(p=str;p!='\0';[++) if(*p>='a' && *p<='z'){q=p;break;} return q;/*将所求的指针返回*/}main(){ char ps[30]; char *x; x=fdl(ps); if(x!=NULL) { printf("The first chr is %c\n&quo 阅读全文
posted @ 2012-10-18 12:50 pythonschool 阅读(289) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h>void dia(int a[], int n)/*数组传的其实是地址*/{ int i; for(i=0;i<n;i++) { if(a[i]%2==0) a[i]*=2; else a[i]*=3; }}main(){ int x[8]={11,12,13,14,15,16,17,18},i; dia(x,8); for(i=0;i<8;i++)printf("%3d",x[i]); getchar();}http://www.pythonschool.com/python/10.htm... 阅读全文
posted @ 2012-10-18 12:48 pythonschool 阅读(3652) 评论(0) 推荐(0) 编辑
摘要:getch功 能 在windows平台下从控制台无回显地取一个字符,在linux下是有回显的。用 法 int getch(void); 在linux平台下时(即包含的是curses.h),还应该在使用函数之前使用initscr(),使用完毕之后调用endwin().否则的话不需输入就会返回。 #include <stdio.h> #include <curses.h> //linux 下 #include <conio.h> //window 平台 int main(void) { char ch; initscr();//linux 下 printf(&q 阅读全文
posted @ 2012-10-18 12:46 pythonschool 阅读(875) 评论(0) 推荐(0) 编辑
摘要:#define STRICT 的意思是让编译器进行严格类型检查 #define WIN32_LEAN_AND_MEAN 的意思是让编译器去除不经常用的头文件(一般包含windows.h要包含一堆用不到的头文件) _T("...")是为了兼容宽字符和UNICODE###通过查看 头文件得知WIN32_LEAN_AND_MEAN和STRICT 的作用是决定在编译的时候是否加载多余的头文件 是一种优化宏#ifndef WIN32_LEAN_AND_MEAN#include <cderr.h>#include <dde.h>#include <ddem 阅读全文
posted @ 2012-10-18 12:41 pythonschool 阅读(329) 评论(0) 推荐(0) 编辑
摘要:例如输入:0 3 5 7 -1input:0123456789output:0123567程序分析:输入两段字串间隔如:(0 3) (5 7) -1是结束符/*** This program reads input lines from the standard input and prints** each input line, followed by just some portions of the lines, to** the standard output.**** The first input is a list of column numbers, which ends w 阅读全文
posted @ 2012-10-18 12:35 pythonschool 阅读(283) 评论(0) 推荐(0) 编辑
摘要:#include <time.h>#include <stdlib.h>#include <stdio.h>#include <conio.h>main(){ char c; clock_t start, end; time_t a, b; double var; int i, guess; int YY; srand(time(NULL)); printf("do you want to play it.('y' or 'n') \n");loop: while((c=getchar()) = 阅读全文
posted @ 2012-10-18 12:28 pythonschool 阅读(671) 评论(0) 推荐(0) 编辑
摘要:当你运行一个C程序,出现This system does not support fullscreen mode.Choose 'Close' to terminate the application.是由于win7下已经不支持16位DOS全屏运行了您的WIN7系统无法支持该程序的全屏模式,因此建议您窗口化运行该程序,可以靠游戏窗口化工具实现其中之一的解决方法:一.下载 DOSBox 0.73http://sourceforge.net/projects/dosbox/files/dosbox/0.73/DOSBox0.73-win32-installer.exe/downlo 阅读全文
posted @ 2012-10-18 12:20 pythonschool 阅读(8350) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h>main(){FILE *fp;char ch, st[2000]; if((fp=fopen("c:/log.log","at++")) == NULL) { printf("Cannot open file strike any keys exit!"); getch(); exit(1); } printf("Input a string:\n"); //gets(st); scanf("%[^\n]", st); fputs(st, fp) 阅读全文
posted @ 2012-10-18 10:01 pythonschool 阅读(2308) 评论(0) 推荐(0) 编辑
摘要:#include "string.h"#include <vector>void CAutoZipDlg::OnBnClickedOk() { using namespace std; vector<CString> strVec; CString teststr = GetCommandLine(); //retrives the command-line string for the current process. CString outputstr; int flag = 0; for(int i = 0;i < teststr.Get 阅读全文
posted @ 2012-10-18 09:48 pythonschool 阅读(1047) 评论(0) 推荐(0) 编辑
摘要://writeby: lhsbqb//date:2012-10-17//title:VC++语言如何输出当前日期,如何获取当前日期#include "time.h"#include "iostream.h"#include "windows.h"int main(int argc, char* argv[]){ time_t nowTime; while(true) { time(&nowTime); struct tm *sysTime = localtime(&nowTime); system("titl 阅读全文
posted @ 2012-10-18 09:41 pythonschool 阅读(407) 评论(0) 推荐(0) 编辑
摘要:'------------------------------------------------------------------------------'FILE DESCRIPTION: 为开发环境添加批量注释或取消注释'------------------------------------------------------------------------------Sub SetSelNote() 'Sun DESCRIPTION:过程SetSellNote用于将选中的文本转换为注释 dim CurWin set CurWin = Active 阅读全文
posted @ 2012-10-16 17:30 pythonschool 阅读(888) 评论(0) 推荐(0) 编辑

刘华世的官方博客
点击右上角即可分享
微信分享提示