上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 26 下一页
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1032View Code #include"iostream"using namespace std;int i,j,Max=0;int fun(int x,int y){ for(i=x; i<=y; i++) { int count=1; int xx=i; while(xx!=1) { if(xx%2!=0) xx=3*xx+1; else xx=xx/2; count++; } if(count>Max) Max=count; } return Max;}int mai 阅读全文
posted @ 2011-03-31 17:44 聊聊IT那些事 阅读(317) 评论(0) 推荐(0) 编辑
摘要: http://www.blogjava.net/dongwq/archive/2009/10/25/299653.html 阅读全文
posted @ 2011-03-29 16:21 聊聊IT那些事 阅读(263) 评论(0) 推荐(0) 编辑
摘要: View Code //按矩阵对角线输出问题#include"iostream"#define M 50using namespace std;int main(){ int n,i,j; int a[M][M]; while(cin>>n) { for(i=0;i<n;i++) { for(j=0;j<n;j++) cin>>a[i][j]; } int k=0; for( k=1; k<=2*n-1;k++) { for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(i+j==k-1)// 阅读全文
posted @ 2011-03-28 21:25 聊聊IT那些事 阅读(378) 评论(0) 推荐(0) 编辑
摘要: dijkstra#include"iostream"#define Max 999999using namespace std;int map[1001][1001];int visit[1001];int n,m;int a,b,time;int i,j,k,_min;int len;void DJ(){ for(i=1;i<=len;i++) { _min=Max; for(j=1;j<=len;j++) { if(!visit[j] && map[0][j]<_min) { _min=map[0][j]; k=j; } } if(_m 阅读全文
posted @ 2011-03-28 18:48 聊聊IT那些事 阅读(416) 评论(0) 推荐(0) 编辑
摘要: View Code #include"iostream"using namespace std;int main(){ int n,i,j; int b[720][720]; while(cin>>n) { memset(b,0,sizeof(b)); if(n==1) cout<<n<<endl; else { i=1,j=1; int k=1; for(int t=1; t<n ; t++) { while(j<=n-i+1&&j>=i) //横行->rigth { b[i][j]=k++; i 阅读全文
posted @ 2011-03-27 11:49 聊聊IT那些事 阅读(281) 评论(0) 推荐(0) 编辑
摘要: View Code #include"iostream"using namespace std;int main(){ int n; char ch[1000]; int i; scanf("%d\n",&n); // cin>>n;cout<<endl; while(n--) { gets(ch); int count=0; if(!(ch[0]>='a'&&ch[0]<='z')&&ch[0]!='_'&&!(c 阅读全文
posted @ 2011-03-26 20:51 聊聊IT那些事 阅读(793) 评论(0) 推荐(0) 编辑
摘要: 很繁琐,花了将近两个小时。。。。。。。View Code #include"iostream"using namespace std;int main(){ char a[100]; int i,j,L; while(scanf("%s",a)!=EOF) { L=strlen(a); int num=0,zf=0,sign=0; for(i=0;i<L;i++) { if(a[i]>='0'&&a[i]<='9') { num=1;} if(a[i]>='A'&am 阅读全文
posted @ 2011-03-26 10:44 聊聊IT那些事 阅读(365) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1257导弹拦截#include"iostream"#define M 50000using namespace std;int n;int a[M];int i,j;int used[M];int flag=0;int main(){ while(cin>>n) { for(i=0;i<n;i++) cin>>a[i]; memset(used, 0 ,sizeof(used)); flag=0; for(i=0; i<n; i++) { if(used 阅读全文
posted @ 2011-03-25 18:54 聊聊IT那些事 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 带路径的数塔#include"iostream"using namespace std;int main(){ int a[100][100],b[100]; int i,j; int n; while(cin>>n) { for(i=0;i<n;i++) for(j=0;j<=i;j++) cin>>a[i][j]; int t=0; int y=a[0][0]; for(i=n-2;i>=0;i--) { int max=0,k=0; for(j=0;j<=i;j++) { if(a[i+1][j]>a[i+1][j 阅读全文
posted @ 2011-03-25 18:53 聊聊IT那些事 阅读(357) 评论(0) 推荐(0) 编辑
摘要: 1 #include"iostream" 2 #define M 50000 3 using namespace std; 4 int n; 5 int a[M]; 6 int i,j; 7 int used[M]; 8 int flag=0; 9 int main()10 {11 while(cin>>n)12 {13 for(i=0;i<n;i++)14 cin>>a[i];15 memset(used, 0 ,sizeof(used));16 flag=0;17 for(i=0; i<n; i++)18 {19 if(used[i] 阅读全文
posted @ 2011-03-23 18:45 聊聊IT那些事 阅读(335) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 26 下一页