- 博客(61)
- 资源 (16)
- 收藏
- 关注
原创 POJ 1306 Combinations
CombinationsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 8013 Accepted: 3746DescriptionComputing the exact number of ways that N things can be taken
2013-10-29 22:01:48 1135
原创 STL容器学习第一天
容器:管理序列的类,通过容器类提供的成员函数,实现各中队序列中元素的操作。STL提供了各种容器类模板,通常这些模板类包括:向量(vector),列表(list),双队列(deque),集合(set),多重集合(multiset),映射(map),多重映射(multimap)。vector可以认为是动态数组;list是由节点组成的双线列表,每个节点包括一个元素;双队列(deq
2013-10-29 13:04:59 936
原创 开关语句switch的几点说明
用途:主要用来解决多层if语句嵌套带来的可读性降低问题。使用:switch(表达式) { case 常量表达式1:语句1; ..... default :语句n+1; }说明;1.switch后面括号里的表达式
2013-10-29 08:57:01 1625
原创 1!到n!的和
#includeusing namespace std;int main(){ int sum=0; for(int i=1,j=1;i { j*=i; sum+=j; } cout system("pause"); return 0;} 这种算法比较巧
2013-10-28 23:32:49 784
原创 关于数组的几点总结
定义:int a[10];int *p;源代码:#includeusing namespace std;int main(){ int a[10]; int *p,i; for(i=0;i a[i]=i; p=a; for(i=0;i {
2013-10-28 22:30:19 748
原创 C++之内置(内嵌、内联)函数
函数调用需要一定的时间和空间开销,函数调用前要进行“现场保护”,调用结束后要进行“现场恢复”,同时参数要占用一定的内存。函数调用过程:1.程序先执行函数调用之前的语句; 2.流程的控制转移到被调用函数的入口处,同时进行参数传递; 3.执行被调用函数中中的语句
2013-10-28 21:58:02 1080 1
原创 数据结构线性表之顺序表解说
线性表的概念就不多说了,相信看过数据结构的人都明白...我想说的是线性表中的顺序表。首先定义一个新的结构体:typedef struct { int *elem
2013-10-28 19:39:30 851
原创 数据结构线性表之顺序表实作
#include#includeusing namespace std;#define LIST_INIT_SIZE 100 //线性表存储空间的初始分配量#define LISTINCREMENT 10 //线性表存储空间的分配增量typedef struct {int *elem; //存储空间基址int length
2013-10-28 19:20:29 909
原创 C语言中文件的操作
文件:一般指存放在外部介质上数据的集合。文件名:文件路径+文件名主干+文件后缀 ,如 d:\cc\temp (路径)+file1(文件主干名)+.dat(后缀)文件分类:ASCII文件 和 二进制文件 ,两中类型的存储方式不同。例如:存放整数 10 000 ;在内存中表示为 0 01 0 0 1 1 1 0 0 0 1 0 0 0 0;以ASCII形式保
2013-10-27 20:45:29 896
原创 C++中*和&的使用
#includeusing namespace std;void Change(int *);//函数声明,参数列表只写明类型就可以了int main(){ int n=99; int *p=&n; //地址赋值 cout Change(p); Change(&n); system("pause");
2013-10-27 13:16:21 1035
原创 C语言中动态分配内存
什么是内存动态分配:全局变量是分配在内存中的静态存储区的,非静态的局部变量(包括形参)是分配在内存中的动态存储区的,这个存储区是一个称为栈的区域。所谓动态分配内存指的是C语言允许建立内存动态分配区域,需要时开辟,不需要时释放,这个动态存储区成为堆。怎样建立内存的动态分配:主要有四个库函数:malloc calloc free realloc 1.malloc
2013-10-27 10:07:09 1547
原创 关于C++和C中字符串的几点说明
众所周知,C语言中用字符数组模拟字符串;而在C++中,标准库中已经包括了字符串类,可以说使用更简单。几个函数的说明:cin.get( ch ),cin.get( array, n, 终止字符).不多说了,直接看一段简单的程序吧,这样理解更快。#include#include //用到了c语言中测量字符串长度的函数 strlen(数组名)
2013-10-26 22:52:47 827
原创 C++中数组初始化的方法级不同方法之间的差别
定义两个数组:arrayA[size],arrayB[size];初始化数组arrayA[size]:for(int i=0;i arrayA[i]=i;若果数组没有经过初始化,则其内容是不确定的。初始化数组arrayB[size]:arrayB[size]={0,1,2};这两种方法之间的差别:若用第一种方
2013-10-26 22:08:19 862
原创 变量的存储类别
变量的存储类别:主要针对时间属性,引出存储期概念。存储期:静态存储期 和 动态存储期。静态存储期:程序运行开始分配固定存储空间;动态存储期:程序运行期间动态的分配和释放内存。存储期有四种:自动的(auto),静态的(static),寄存器的(register),外部的(extern)。自动变量:函数的形参,函数中定义的变量。默认情况即为自动变
2013-10-25 09:20:36 941
原创 Border
1649. BorderTime Limit: 1.0 Seconds Memory Limit: 65536KTotal Runs: 655 Accepted Runs: 285You are to write a program that draws a border around a closed path into a bitmap, as
2013-10-24 23:22:07 1133
原创 I Think I Need a Houseboat
Time Limit: 1.0 Seconds Memory Limit: 65536KTotal Runs: 3862 Accepted Runs: 1367Fred Mapper is considering purchasing some land in Louisiana to build his house on. In the process of
2013-10-24 22:04:58 852
原创 线性表之链表实作一
//线性表的一个例子#includeusing namespace std;typedef struct List{ int num; struct List *next;//指向下一个元素 }list,*listp;//前者代表该种数据类型,后者代表该种数据类型的指针 void InitList(listp &first){
2013-10-24 15:23:49 745
原创 关于C++中new和delete的几点说明
用途:动态分配和撤销内存空间,和C语言中的malloc和free的作用一样,区别在于new和delete的效率更高。注意:new和delete不是函数,而是C++提供的运算符,和加减乘除运算符一样。使用:new 类型 [初值],如 new int [100]; delete 指针变量 (对变量) delete
2013-10-24 13:59:33 1028
原创 数据结构之线性表(linear_list)一
线性结构的特点(非空 有限 集合):1、存在唯一一个头元素;2、存在唯一一个尾元素;3、除头元素外,每个元素都有唯一前驱;4、除尾元素外,每个元素都有唯一后继;线性表中数据元素的组成:若干个数据项,此种情况下,通常把线性表称为记录;含有大量记录的线性表称为文件。注意:同一线性表中的元素必定具有相同特性(组成、顺序),相邻元素间有序偶关系。序偶
2013-10-24 13:45:20 1023
原创 动态规划一
什么是动态规划: 动态规划(dynamicprogramming)是运筹学的一个分支,是求解决策过程(decisionprocess)最优化的数学方法。20世纪50年代初美国数学家R.E.Bellman等人在研究多阶段决策过程(multistepdecision process)的优化问题时,提出了著名的最优化原理(principleof optimality),把多阶段过程转
2013-10-24 08:47:49 847
原创 最近这几日
谁的青春不曾迷茫,只是不轻易悲伤。 最近这几天,感觉荒废了,设么事情都没做,而且之前定的目标也没有完成,原因有很多。最重要的原因是,突然感觉很迷茫,不知道该怎么办,更没有心思做事情。ACM没做,Qt没学,上课也没认真听讲。哎。。。说实话,我是很讨厌这种感觉了。。。对于一个还有上进心的人来说,这无疑是一种折磨。不管怎么说,做什么事情如果不能坚持,最终也不可能取得什么理想的结果,
2013-10-23 23:20:20 704
原创 Number Sequence
Given a positive integer number, we want to generate a number sequence with the following rules:If the current number is 1, the process will be terminated. Otherwise, if the current number is even,
2013-10-23 08:31:41 892
原创 Speed Limit
Time Limit: 1.0 Seconds Memory Limit: 65536KTotal Runs: 2602 Accepted Runs: 1751Bill and Ted are taking a road trip. But the odometer in their car is broken, so they don't know how man
2013-10-23 08:19:27 1267
原创 Qt学习第四天
头文件:#ifndef DIALOG_H#define DIALOG_H#include //前置申明了一些将要用到的类class QGridLayout; //网格布局class QVBoxLayout; //垂直布局class QPushButton; //按钮class QSpacerItem; //分隔符class QGroupBox;
2013-10-18 22:45:56 1348
原创 QSpacer用法简介
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);horizontalLayout->addWidget(button1);horizontalLayout->addItem(horizontalSpacer);horizontalLayout->addWidget
2013-10-18 12:28:07 10681 4
原创 Browsing History
Time Limit: 1000msCase Time Limit: 1000msMemory Limit: 32768KB64-bit integer IO format: %I64d Java class name: MainSubmit StatusFont Size: + -One day when you are goin
2013-10-18 12:00:35 1488
原创 Qt学习第三天
头文件:#ifndef GOTOCELLDIALOG_H#define GOTOCELLDIALOG_H#includeclass QLabel;class QLineEdit;class QPushButton;class GOTOCELLDIALOG:public QDialog{ Q_OBJECTpublic:
2013-10-17 23:22:48 814
原创 Rounders
Introduction:For a given number, if greater than ten, round it to the nearest ten, then (if that result is greater than 100) take the result and round it to the nearest hundred, then (if that result
2013-10-17 13:02:05 1030
原创 Just the Facts
The expression N!, read as "N factorial," denotes the product of the first N positive integers, where N is nonnegative. So, for example, N N! 0 1 1 1 2 2 3
2013-10-16 22:40:49 1114
原创 Degree
CXB would like to find out the maximum repeat frequency in a figure sequence. For instance, the figure sequence as follows: 5,6,7,5,1. According to this sequence, we can draw a conclusion that 5 is
2013-10-16 22:03:32 1044
原创 Qt学习第二天
源代码及注释头文件:finddialog.h#ifndef FINDDIALOG_H#define FINDDIALOG_H#include//一下数行前置声明了一些要用到的类,之所以用前置声明,是因为这样可以编译速度加快class QCheckBox;class QLabel;class QLineEdit;class QPushB
2013-10-16 20:26:05 855
原创 Qt学习第一天(2)
#include#includeint main(int argc,char *argv[]){ QApplication app(argc,argv); QPushButton *button=new QPushButton("Quit"); //将应用程序的槽函数和button的点击信号连接 QObject::connect(button
2013-10-15 22:56:49 603
原创 Qt学习第一天(1)
#include#includeint main(int argc,char *argv[]){ QApplication app(argc,argv); //在Qt中可以使用一些HTML样式格式,使输出变得更加丰富 QLabel*label=new QLabel("Hello"" color=red>Qt!"); label->show();
2013-10-15 22:52:07 668
原创 Qt学习第一天
#include#include#include#includeint main(int argc,char *argv[]){ QApplication app(argc,argv); //管理整个应用程序需所要用到的资源,为每个应用程序所必须 QWidget *window=new QWidget; //创建一个QWidget对象
2013-10-15 22:44:13 748
原创 Differences
CXB attended an interview and the interviewer given him a problem. The problem asked him to be in a sequence to find the difference between the maximum and minimum values.InputThe first line of th
2013-10-15 22:04:13 1037
原创 Change Base
Given an integer m in base B (2 ≤ B ≤ 10) (m contains no more than 1000 digits), find the value of the integer m in base 10, output the result modulo 10007.InputThe first line of the input is a
2013-10-15 21:20:25 1029
原创 C语言学习总结
1.C语言并不提供输入输出,而是由C函数库实现的输入输出。2.putchar(c)输出一个字符,包括换行、空格3、getchar()输入一个字符,包括空格、换行4.printf(格式控制,输出列表) 普通字符原样输出,也可以输出空格、逗号、换行。%f 输出单精度时保留6-7为有效数字,输出双精度时,保留15-16位有效数字。5.scanf(格式控制,地址列表)格式控制中的普通字符要
2013-10-15 12:17:05 955
原创 关于scanf,printf以及c中字符串的一些总结
在做ACM题的时候,如果需要输入的数据量较大,一般都会提示使用scanf和printf来进行输入和输出。不可否认,这两个函数功能比cin和cout强大,而且效率更高。 在用scanf输入字符串的时候,它会忽略前面的空格,同时以遇到的 空格 作为字符串结束的标志。例如:读入 Join WTommy 80,会把这三个字符串分开读,而不会把它们都读到一个字符串内。哎,因为
2013-10-15 00:15:16 1800
转载 scanf()如何读取一整行(转)
用scanf获取一行字符串包括空格的以及C语言函数其内容为#includeint main(){ char str[1024]; scanf("%[^\n]", &str); ... return 0;}说明:在scanf函数中, 可以使用%c来读取一个字符, 使用%s读取一个字符串, 但是读取字符
2013-10-14 22:33:43 4370 4
原创 TJU Easier Done than Said?
Password security is a tricky thing. Users prefer simple passwords that are easy to remember (like buddy), but such passwords are often insecure. Some sites use random computer-generated passwords (
2013-10-13 20:56:58 1184
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人