摘要: //仙岛求药#include <iostream> #include <cstdio> #include <cstring> #include <queue>using namespace std;typedef struct _node { int x,y,z; }node;const int N=100; const int b[4][2]={{1,0},{0,1},{-1,0},{0,-1}};//对四个方向打表 bool map[N][N];//纪录走过的点 char graph[N][N]; int n,m; node sstart,s 阅读全文
posted @ 2012-05-10 19:31 逝者*恋世 阅读(246) 评论(1) 推荐(0) 编辑
摘要: 此乃牛人大作,最近觉得学的不够好,网上搜的,很多。据说是关于C/C++指针下载人数最多的教程。该教程没有一般书讲的那么枯燥,将一个很容易搞不清楚的问题讲的很清楚。个人觉得只有最后一部分,有点无所谓去了解。向原著者致敬,大家可以去下载pdf格式的教程,因为pdf格式的字符图不会发生变形。会看得舒服一点。本想给原著者来个链接,无奈,这篇写得太有名了,大家都贴来贴去都不知道源链接在那里了,抱歉。作者:白云小飞《彻底搞定C指针》第一篇 变量的内存实质一.先来理解C语言中变量的实质 要理解C指针,我认为一定要理解C中“变量”的存储实质,所以我就从“变量”这个东西开始讲起吧! 先来理解理解... 阅读全文
posted @ 2012-05-10 19:30 逝者*恋世 阅读(171) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>char a[30][30];int d(int h,int l,int n,int m){if(h<0||l<0||h>n-1||l>m-1)return 0;else if(a[h][l]=='#')return 0;else if(a[h][l]=='.'){a[h][l]='#';return1+d(h,l-1,n,m)+d(h,l+1,n,m)+d(h-1,l,n,m)+d(h+1,l,n,m);}}int main() 阅读全文
posted @ 2012-04-26 19:59 逝者*恋世 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 问题描述 人自出生起就有体力,情感和智力三个生理周期,分别为23,28和33天。一个周期内有一天为峰值,在这一天,人在对应的方面(体力,情感或智力)表现最好。通常这三个周期的峰值不会是同一天。现在给出三个日期,分别对应于体力,情感,智力出现峰值的日期。然后再给出一个起始日期,要求从这一天开始,算出最少再过多少天后三个峰值同时出现。问题分析 首先我们要知道,任意两个峰值之间一定相距整数倍的周期。假设一年的第N天达到峰值,则下次达到峰值的时间为N+Tk(T是周期,k是任意正整数)。所以,三个峰值同时出现的那一天(S)应满足 S = N1 + T1*k1 = N2 + T2*k2 = N3 + T3 阅读全文
posted @ 2012-04-23 20:02 逝者*恋世 阅读(746) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>int main(){ int a; scanf("%d",&a); int a10=0; int mult=1; while(a){ a10+=mult*(a%10); mult*=8; a/=10; } printf("%d\n",a10); return 0;} 阅读全文
posted @ 2012-04-18 20:32 逝者*恋世 阅读(152) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stdio.h>#include<string.h>#define N 80using namespace std;int main(){ char test[N]; int counta=0,counte=0,counti=0,counto=0,countu=0; gets (test); int i; for(i=0;i<N && test[i]!='\0';i++){ if(test[i]=='a') counta++; else if(test 阅读全文
posted @ 2012-04-18 20:26 逝者*恋世 阅读(166) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <cmath>using namespace std;int find(int x){ int i; for(i = 1; ;i++){ if(pow((double)2, i-1) <= x && x < pow((double)2, i)) return i; }}int main(){int n, high, m, low;int nCount, i;while (cin >> m >> n && m && n){nCount 阅读全文
posted @ 2012-04-18 19:47 逝者*恋世 阅读(127) 评论(0) 推荐(0) 编辑
摘要: #include <string.h>#include <iostream>using namespace std;#define MAX 200unsigned int num[MAX+10];unsigned int num1[MAX+10];int main(){ string str1,str2; cin>>str1>>str2; memset(num,0,sizeof(num)); memset(num1,0,sizeof(num1)); int len = str1.length();int index = 0; for (int i 阅读全文
posted @ 2012-04-17 20:31 逝者*恋世 阅读(431) 评论(0) 推荐(1) 编辑
摘要: #include<string>#include<iostream>usingnamespacestd;#defineMAX200intnum1[MAX+10];intnum2[MAX+10];unsignedinttotal[MAX+10];intSub(inta,intb){if(b>=a){if(a==b)return0;elsereturn-1;}inti=0;for(;a>b;i++){b++;}returni;}intmain(){intn;cin>>n;while(n--){memset(num1,0,sizeof(num1));m 阅读全文
posted @ 2012-04-16 19:43 逝者*恋世 阅读(273) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <stdio.h>using namespace std;int main(){int num;cin>>num;int graphic[100][100];int i=0,j=0,rightEst,bottumEst;int width=0,lengh=0;for(i=0;i<num;i++){for(j=0;j<num;j++){scanf("%d",&graphic[i][j]);if(graphic[i][j]==0){rightEst=i;bottumE 阅读全文
posted @ 2012-04-16 19:23 逝者*恋世 阅读(134) 评论(0) 推荐(0) 编辑