摘要: 工具: MicrosoftVisualStudio,CodeWright,SharpDevelop,VisualSlickEdit.基础类型和引用类型: 基础类型:堆栈中分配内存 引用类型:堆中分配内存 基础类型→引用类型:装箱 引用类型→基本类型:拆箱别名: int == System.Int32 long == System.Int64数组 阅读全文
posted @ 2012-11-27 21:47 无殇天下 阅读(131) 评论(0) 推荐(0)
摘要: 题目:蜜蜂的蜂巢具有优美的几何结构。某宾馆拥有10000个房间就是这样设计的,宾馆用连续的正整数为每个房间编号。如下图。当游客入住该宾馆时,需要知道自己和哪些房间是相邻的。例如 14号房间和5、13、15、28、29、30六个房间相邻。输入首先输入一个正整数N,表示需要判断的房间数(0<N<100)然后的N行,每行一个正整数Fi,表示房间号。(0<Fi <1000)输出对于每个输入的房间号Fi,在一行中输出相邻的其它6个房间号(按照从小到大的次序,用1个空格分割)样例输入2314样例输出1249101151315282930这题相当复杂,首先要好好找规律何为拐角(可以看 阅读全文
posted @ 2012-05-10 23:44 无殇天下 阅读(248) 评论(0) 推荐(0)
摘要: 格式化输出double a;C语言C++位数指定为nprintf("%nf",a);cout.sef(ios::shopoint);cout.position(n);小数点后指定n位printf("%.nf",a);cout.sef(ios::fixed);cout.sef(ios::shopoint);cout.position(n); 阅读全文
posted @ 2012-05-04 22:23 无殇天下 阅读(119) 评论(0) 推荐(0)
摘要: 使用C++标准库的快速排序函数C++的标准库stdlib.h中提供了快速排序函数。请在使用前加入对stdlib.h的引用:#include <cstdlib> 或 #include <stdlib.h>qsort(void* base, size_t num, size_t width, int(*)compare(const void* elem1, const void* elem2))参数表*base: 待排序的元素(数组,下标0起)。num: 元素的数量。width: 每个元素的内存空间大小(以字节为单位)。可用sizeof()测得。int(*)compare: 阅读全文
posted @ 2012-05-01 17:44 无殇天下 阅读(392) 评论(0) 推荐(0)
摘要: 题目:USACONOCOW结果:代码:#include<fstream>using namespace std;struct Map{ int length; bool intree;};int length,total,Arc[100][100];Map a[100];int findTheShortest(){ int i,j,shortest=1000000; for(i=0;i<total;i++) if(a[i].intree==false&&a[i].length<shortest) {shortest=a[i].length; ... 阅读全文
posted @ 2012-04-25 13:07 无殇天下 阅读(155) 评论(0) 推荐(0)
摘要: 题目:①、USACO ②、NOCOW注意: ①、两个农场之间可能多条路径,并且长度不同; ②、无向图;代码:#include<stdio.h>#include<assert.h>int main(){ FILE *fin,*fout; fin=fopen("comehome.in","r"); fout=fopen("comehome.out","w"); assert(fin); assert(fout); int Arc[58][58]; int pathNum,i,j,k,length 阅读全文
posted @ 2012-04-24 16:49 无殇天下 阅读(199) 评论(0) 推荐(0)
摘要: 题目:http://ace.delos.com/usacoprob2?a=JLwu8ZOtbGJ&S=maze1 http://www.nocow.cn/index.php/Translate:USACO/maze1#include<iostream>#include<fstream>#include<queue>using namespace std;struct Node{ int num; int link[4];};int main(){ //ifstream fin("1.txt"); //ofstream fout(& 阅读全文
posted @ 2012-04-24 15:06 无殇天下 阅读(116) 评论(0) 推荐(0)
摘要: officeMS officeopen officeLibre officeWps officePDFSumatra PDF (1M) 阅读全文
posted @ 2012-04-21 18:56 无殇天下 阅读(106) 评论(0) 推荐(0)
摘要: 题目:将1,2,3,4,5……n-1,n分成和相等的两个子集,有多少种分法#include<stdio.h>#include<math.h>#include<assert.h>int main(){ FILE *fin,*fout; fin=fopen("1.txt","r"); fout=fopen("2.txt","w"); assert(fin); assert(fout); int N,dp[40][800]={0}; fscanf(fin,"%d", 阅读全文
posted @ 2012-03-25 19:24 无殇天下 阅读(365) 评论(0) 推荐(0)
摘要: 今天我写了最快的算法#include<fstream>using namespace std;int main(){ ifstream fin("numtri.in"); ofstream fout("numtri.out"); int h,tr[1000000],l=0; fin>>h; while(fin>>tr[++l]);//从tr[1]开始存放 l=2; for(int i=1;i<h;i++)//层次 for(int j=0;j<=i;j++)//每层从第零个到最后一个 { if(j==0) . 阅读全文
posted @ 2012-03-11 17:06 无殇天下 阅读(245) 评论(0) 推荐(0)