云中烛火

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

文章分类 -  小程序

摘要:数字三角形 (图3.1-1)示出了一个数字三角形。 请编一个程序计算从顶至底的某处的一条路径,使该路径所经过的数字的总和最大。 ●每一步可沿左斜线向下或右斜线向下走; ●1<三角形行数≤100; ●三角形中的数字为整数0,1,…99;输入数据:573 88 1 02 7 4 44 5 2 6 5输出数据:30 1 #include<stdio.h> 2 #include<stdlib.h> 3 int a[100][100],b[100][100],c[100][100]; 4 int i,j,n; 5 6 void print(int i,int j){ 7 if(( 阅读全文
posted @ 2013-05-03 09:39 云中烛火 阅读(181) 评论(0) 推荐(0)

摘要:Binary String Matching时间限制:3000 ms | 内存限制:65535 KB难度:3描述Given two strings A and B, whose alphabet consist only ‘0’ and ‘1’. Your task is only to tell how many times does A appear as a substring of B? For example, the text string B is ‘1001110110’ while the pattern string A is ‘11’, you should output 阅读全文
posted @ 2013-05-02 21:20 云中烛火 阅读(87) 评论(0) 推荐(0)

摘要:1 #include <stdio.h> 2 #include <string.h> 3 #define N 200 4 5 6 char* largeSum(char s1[200],char s2[200]){ 7 int a[N]={0},b[N]={0},l1,l2,c,k,i; 8 char result[N]; 9 char *result1=result;10 l1=strlen(s1); 11 l2=strlen(s2); 12 if(l1<l2) k=l2; 13 else 14 k=l1;1... 阅读全文
posted @ 2013-04-27 11:42 云中烛火 阅读(249) 评论(0) 推荐(0)

摘要:#include <stdio.h> #include <string.h> #define N 200char result[N];void largeSum(char s1[200],char s2[200]){ int a[N]={0},b[N]={0},l1,l2,c,k,i; l1=strlen(s1); l2=strlen(s2); if(l1<l2) k=l2; else k=l1; c=k; for(i=0;i<l1;k--,i++) a[k]=s1[l1-1-i]-'0'; for(k=c,i=0;i<l2;k--,i 阅读全文
posted @ 2013-04-27 11:22 云中烛火 阅读(139) 评论(0) 推荐(0)

摘要:不吉利的数字时间限制:1000 ms | 内存限制:65535 KB(有刘慧倾情编写)难度:1描述 一些普通的数字在很多人眼里是不吉利。如数字4,谐音“死”,所以很多地方都没有带4的数字:比如新校区澡堂衣柜编号及没有4;再如数字13,在西方人眼中代表着坏运气,也是不吉利的数字,13不出远门,楼层不设第13层等等。 假如某些人认为0是不吉利的数字,并且在他们以后的生活中,记录数据都在不在使用含有0的自然数。 他们记录数的序列是1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,21,22.......n,由于不使用数字0,他们记录的数和我们实际使用的自然数有 阅读全文
posted @ 2013-04-26 20:55 云中烛火 阅读(928) 评论(0) 推荐(0)

摘要:括号配对问题时间限制:3000 ms | 内存限制:65535 KB难度:3描述 现在,有一行括号序列,请你检查这行括号是否配对。 输入 第一行输入一个数N(0 输出 每组输入数据的输出占一行,如果该字符串中所含的括号是配对的,则输出Yes,如果不配对则输出No 样例输入 3 [(]) (]) ([[]()]) 样例输出 No No Yes程序如下:#include<stdio.h>#include<string.h>void test(char a[5000]){char z[5000];char *p=a;int m=0;for(int i=0;i<strle 阅读全文
posted @ 2013-04-26 20:44 云中烛火 阅读(121) 评论(0) 推荐(0)