- 博客(215)
- 资源 (16)
- 收藏
- 关注
原创 数据结构线性表之顺序表解说
线性表的概念就不多说了,相信看过数据结构的人都明白...我想说的是线性表中的顺序表。首先定义一个新的结构体:typedef struct { int *elem
2013-10-28 19:39:30 869
原创 数据结构线性表之顺序表实作
#include#includeusing namespace std;#define LIST_INIT_SIZE 100 //线性表存储空间的初始分配量#define LISTINCREMENT 10 //线性表存储空间的分配增量typedef struct {int *elem; //存储空间基址int length
2013-10-28 19:20:29 931
原创 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 924
原创 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 1055
原创 C语言中动态分配内存
什么是内存动态分配:全局变量是分配在内存中的静态存储区的,非静态的局部变量(包括形参)是分配在内存中的动态存储区的,这个存储区是一个称为栈的区域。所谓动态分配内存指的是C语言允许建立内存动态分配区域,需要时开辟,不需要时释放,这个动态存储区成为堆。怎样建立内存的动态分配:主要有四个库函数:malloc calloc free realloc 1.malloc
2013-10-27 10:07:09 1592
原创 关于C++和C中字符串的几点说明
众所周知,C语言中用字符数组模拟字符串;而在C++中,标准库中已经包括了字符串类,可以说使用更简单。几个函数的说明:cin.get( ch ),cin.get( array, n, 终止字符).不多说了,直接看一段简单的程序吧,这样理解更快。#include#include //用到了c语言中测量字符串长度的函数 strlen(数组名)
2013-10-26 22:52:47 848
原创 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 882
原创 变量的存储类别
变量的存储类别:主要针对时间属性,引出存储期概念。存储期:静态存储期 和 动态存储期。静态存储期:程序运行开始分配固定存储空间;动态存储期:程序运行期间动态的分配和释放内存。存储期有四种:自动的(auto),静态的(static),寄存器的(register),外部的(extern)。自动变量:函数的形参,函数中定义的变量。默认情况即为自动变
2013-10-25 09:20:36 979
原创 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 1173
原创 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 874
原创 线性表之链表实作一
//线性表的一个例子#includeusing namespace std;typedef struct List{ int num; struct List *next;//指向下一个元素 }list,*listp;//前者代表该种数据类型,后者代表该种数据类型的指针 void InitList(listp &first){
2013-10-24 15:23:49 764
原创 关于C++中new和delete的几点说明
用途:动态分配和撤销内存空间,和C语言中的malloc和free的作用一样,区别在于new和delete的效率更高。注意:new和delete不是函数,而是C++提供的运算符,和加减乘除运算符一样。使用:new 类型 [初值],如 new int [100]; delete 指针变量 (对变量) delete
2013-10-24 13:59:33 1057
原创 数据结构之线性表(linear_list)一
线性结构的特点(非空 有限 集合):1、存在唯一一个头元素;2、存在唯一一个尾元素;3、除头元素外,每个元素都有唯一前驱;4、除尾元素外,每个元素都有唯一后继;线性表中数据元素的组成:若干个数据项,此种情况下,通常把线性表称为记录;含有大量记录的线性表称为文件。注意:同一线性表中的元素必定具有相同特性(组成、顺序),相邻元素间有序偶关系。序偶
2013-10-24 13:45:20 1044
原创 动态规划一
什么是动态规划: 动态规划(dynamicprogramming)是运筹学的一个分支,是求解决策过程(decisionprocess)最优化的数学方法。20世纪50年代初美国数学家R.E.Bellman等人在研究多阶段决策过程(multistepdecision process)的优化问题时,提出了著名的最优化原理(principleof optimality),把多阶段过程转
2013-10-24 08:47:49 864
原创 最近这几日
谁的青春不曾迷茫,只是不轻易悲伤。 最近这几天,感觉荒废了,设么事情都没做,而且之前定的目标也没有完成,原因有很多。最重要的原因是,突然感觉很迷茫,不知道该怎么办,更没有心思做事情。ACM没做,Qt没学,上课也没认真听讲。哎。。。说实话,我是很讨厌这种感觉了。。。对于一个还有上进心的人来说,这无疑是一种折磨。不管怎么说,做什么事情如果不能坚持,最终也不可能取得什么理想的结果,
2013-10-23 23:20:20 720
原创 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 960
原创 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 1291
原创 Qt学习第四天
头文件:#ifndef DIALOG_H#define DIALOG_H#include //前置申明了一些将要用到的类class QGridLayout; //网格布局class QVBoxLayout; //垂直布局class QPushButton; //按钮class QSpacerItem; //分隔符class QGroupBox;
2013-10-18 22:45:56 1409
原创 QSpacer用法简介
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);horizontalLayout->addWidget(button1);horizontalLayout->addItem(horizontalSpacer);horizontalLayout->addWidget
2013-10-18 12:28:07 10854 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 1528
原创 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 833
原创 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 1055
原创 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 1143
原创 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 1062
原创 Qt学习第二天
源代码及注释头文件:finddialog.h#ifndef FINDDIALOG_H#define FINDDIALOG_H#include//一下数行前置声明了一些要用到的类,之所以用前置声明,是因为这样可以编译速度加快class QCheckBox;class QLabel;class QLineEdit;class QPushB
2013-10-16 20:26:05 879
原创 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 632
原创 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 687
原创 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 777
原创 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 1056
原创 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 1050
原创 C语言学习总结
1.C语言并不提供输入输出,而是由C函数库实现的输入输出。2.putchar(c)输出一个字符,包括换行、空格3、getchar()输入一个字符,包括空格、换行4.printf(格式控制,输出列表) 普通字符原样输出,也可以输出空格、逗号、换行。%f 输出单精度时保留6-7为有效数字,输出双精度时,保留15-16位有效数字。5.scanf(格式控制,地址列表)格式控制中的普通字符要
2013-10-15 12:17:05 975
原创 关于scanf,printf以及c中字符串的一些总结
在做ACM题的时候,如果需要输入的数据量较大,一般都会提示使用scanf和printf来进行输入和输出。不可否认,这两个函数功能比cin和cout强大,而且效率更高。 在用scanf输入字符串的时候,它会忽略前面的空格,同时以遇到的 空格 作为字符串结束的标志。例如:读入 Join WTommy 80,会把这三个字符串分开读,而不会把它们都读到一个字符串内。哎,因为
2013-10-15 00:15:16 1822
转载 scanf()如何读取一整行(转)
用scanf获取一行字符串包括空格的以及C语言函数其内容为#includeint main(){ char str[1024]; scanf("%[^\n]", &str); ... return 0;}说明:在scanf函数中, 可以使用%c来读取一个字符, 使用%s读取一个字符串, 但是读取字符
2013-10-14 22:33:43 4478 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 1212
原创 TJU Bitwise Reverse
Professor Robby invents a powerful encryption method, but he is too lazy to implement it. So he turns to you for help.In fact, the encryption method is only applied to positive integers. At first, w
2013-10-13 19:12:21 1032
原创 TJU Counting Letters
As a talented student, your boss gave you a task. Given a text string, you should find out which letters appear most frequently.Really simple, isn't it?InputThe first line of the input is the nu
2013-10-12 23:03:18 1209
原创 TJU Root of the Problem
Given positive integers B and N, find an integer A such that AN is as close as possible to B. (The result A is an approximation to the Nth root of B.) Note that AN may be less than, equal to, or g
2013-10-12 22:43:05 782
原创 TJU Hacb knows the gift
Coach Yu will send gifts to ACM teammates. This message was known by Hacb, he send the message to G.D.R at once. But the message was encrypted. If Hacb wants to send an integer x to G.D.R, the massa
2013-10-12 22:05:48 893
转载 C/C++中的64位整数(__int64 and long long)
在做ACM题时,经常都会遇到一些比较大的整数。而常用的内置整数类型常常显得太小了:其中long 和 int 范围是[-2^31,2^31),即-2147483648~2147483647。而unsigned范围是[0,2^32),即0~4294967295。也就是说,常规的32位整数只能够处理40亿以下的数。 那遇到比40亿要大的数怎么办呢?这时就要用到C++的64位扩展了。不同的编
2013-10-12 16:19:32 2251
原创 TJU Super Square
If N Ns are added together, we know that it's the square of N. Well, if N Ns are multiplied together, we call it a super square of N. For example, the square of 3 is 3+3+3=9, while the super square
2013-10-10 22:31:42 1048
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人