摘要: Problem Description今天的上机考试虽然有实时的Ranklist,但上面的排名只是根据完成的题数排序,没有考虑每题的分值,所以并不是最后的排名。给定录取分数线,请你写程序找出最后通过分数线的考生,并将他们的成绩按降序打印。Input测试输入包含若干场考试的信息。每场考试信息的第1行给出考生人数N ( 0 < N< 1000 )、考题数M ( 0 < M < = 10 )、分数线(正整数)G;第2行排序给出第1题至第M题的正整数分值;以下N行,每行给出一名考生的准考证号(长度不超过20的字符串)、该生解决的题目总数m、以及这m道题的题号(题目号由1到M)。 阅读全文
posted @ 2012-02-22 23:48 某某。 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 字符串的函数2012-02-12 15:59:20标签:字符串添加标签>>函数名: strcat功 能: 字符串拼接函数用 法: char *strcat(char *destin, char *source);程序例:#include <string.h>#include <stdio.h>int main(void){ char destination[25]; char *blank = " ", *c = "C++", *Borland = "Borland"; strcpy(destina 阅读全文
posted @ 2012-02-22 23:45 某某。 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 杭电1002 A+Bproblem。。。交了七遍,最后发现原来有五遍是因为没删测试输出= =、、2012-02-19 09:34:23标签:字符串水题添加标签>>A + B Problem IITime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 98985Accepted Submission(s): 18771Problem DescriptionI have a very simple problem for you. Given 阅读全文
posted @ 2012-02-22 23:42 某某。 阅读(399) 评论(0) 推荐(0) 编辑
摘要: /* 做这道题之前我用了一上午头的时间都没有明白怎么变成后缀式,但是一旦知道后缀式怎么变成表达式的时候思路就很清晰了(感谢秦川同学,尚灿芳同学//scanf= =...,赵鹏同学对小的不离不弃不厌倦= =。。。); 转换成后缀式无非就是遵循保证优先级高或者是相等时候入栈的的先打出来(此题中即先出栈打印),遇到()时先把括号里的输出在输出括号外面的; */ #include<stdio.h> #include<stdlib.h> struct stack { char c[100]; int top; }; int Push ( struct stac... 阅读全文
posted @ 2012-02-22 23:36 某某。 阅读(286) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 4 struct Lnode/*以为当时做的题目没有告诉我是多少位的数字所以我选择了长度不受限的链栈*/ 5 { 6 int num; 7 struct Lnode *next; 8 }; 9 10 int Push(struct Lnode *top , int x)//压入数据 11 { 12 struct Lnode *p = (struct Lnode*)malloc(sizeof(struct Lnode)); 13 p->nu... 阅读全文
posted @ 2012-02-22 23:35 某某。 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<stdlib.h> 3 struct node 4 { 5 int num; 6 struct node *next; 7 }; 8 int n,k; 9 struct node * input(int n) 10 { 11 int i; 12 struct node *head,*tail,*p; 13 14 p = (struct node *)malloc(sizeof(struct node)); 15 p->next = NULL... 阅读全文
posted @ 2012-02-22 23:33 某某。 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 3函数名称: malloc 函数原型: void * malloc(unsigned size); 函数功能: 分配size字节的存储区 函数返回: 所分配的内存区地址,如果内存不够,返回0 4函数名称: realloc//内存数据清零 函数原型: void * realloc(void * p,unsigned size); 函数功能: 将p所指出的已分配内存区的大小改为size,size可以比原来分配的空间大或小 函数返回: 返回指向该内存区的指针.NULL-分配失败 1函数名称: calloc 函数原型: void * calloc(unsigned n,unsigned... 阅读全文
posted @ 2012-02-22 23:32 某某。 阅读(1606) 评论(0) 推荐(0) 编辑
摘要: /*发现写长代码的时候写分成小部分去实现很有必要,容易差错*/#include<stdio.h> #include<stdlib.h> struct node { int num; struct node* next; }; struct node * input(int n) { int i; struct node *head,*tail,*p; head = tail = (struct node *)malloc(sizeof(struct node)); head->next = NULL; for... 阅读全文
posted @ 2012-02-22 23:31 某某。 阅读(245) 评论(0) 推荐(0) 编辑
摘要: 1 /*这题的错误是和同学熬夜找出来的呃= =。。。*/ 2 3 #include<stdio.h> 4 #include<string.h> 5 int main() 6 { 7 int front,rear,i,f,j,n,t,q[10000]; 8 char s[20]; 9 scanf("%d",&n); 10 rear =0,front=0; 11 for(i=0;i<n;i++) 12 { 13 rear=i; 14 sca... 阅读全文
posted @ 2012-02-22 23:30 某某。 阅读(156) 评论(0) 推荐(0) 编辑
摘要: /*其实完全不用建立结构体,但是由于刚学栈的结构体形式所以才用一下,希望王旭老师多多指教*/ #include<stdio.h> #include<stdlib.h> struct stack { int c[100]; int top; }; int Push ( struct stack *p,int n) { if( p->top == 49 ) return 0; else { p->top++; p->c[p->top] =n; return 1; ... 阅读全文
posted @ 2012-02-22 23:29 某某。 阅读(259) 评论(0) 推荐(0) 编辑
摘要: 1 #include <stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int i,k,l1,l2,ii,j,leap; 6 char s1[1001],s2[1001]; 7 while(gets(s1)!=NULL) 8 { 9 gets(s2); 10 l1=strlen(s1); 11 l2 = strlen(s2); 12 leap =0; 13 14 ... 阅读全文
posted @ 2012-02-22 23:27 某某。 阅读(398) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> /*快速排序是的思想就是每一趟让标记右边的大于或小于标记位置的数,而且是让每一次的标记位置为空让标记位置l或g与i或h交换*/ 2 int qsort2(int a[],int l,int h) 3 { 4 int key,i; 5 key = a[l]; /*取轴值记录关键字*/ 6 while(l<h) /*从表的两端交替地向中间扫描,无等于号!!!!*/ 7 { 8 while(l<h && key <= a[h])h--; /*将比轴值记录大的交换到高端*/ 9 ... 阅读全文
posted @ 2012-02-22 23:26 某某。 阅读(3488) 评论(0) 推荐(0) 编辑
摘要: 1 void hebing(int a[],int l,int mid,int h) 2 { 3 int i,x[100]; 4 int j,y[100]; //将要合并的两部分存放在两个数组中 5 int n1 = mid-l+1;//因为下面定义的时候是i = 1,j = 1; 6 int n2 = h-mid; 7 for( i=1;i<=n1;i++) 8 { 9 x[i] = a[l+i-1];//a是从1开始的,且此处包含了mid 10 } 11 for( i=1;i... 阅读全文
posted @ 2012-02-22 23:24 某某。 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 这道题我“第一次抱着试试看的态度”就叫上去了,结果直接AC。贴着道题主要是给了我一些经验,首先看到一道题想到的就是这道题有没有陷阱,比如内存过大,或者数据溢出等等,或者很恶心的最前面和最后面会不会是特殊情况(这道题就是),还有是否当输入0.1.2的时候按着自己的思路来的话会是和答案不一样的结果?字符串扩展Time Limit: 1000MS Memory limit: 65536K题目描述Tom有些时候为了记录的方便,常常将一些连续的字符用扩展符'-'简单表示。比如abcdefg可以简写为a-g,即用起始的字符和终止字符中间加上一个扩展符'-'来表示这个字符串。 阅读全文
posted @ 2012-02-22 23:22 某某。 阅读(562) 评论(0) 推荐(0) 编辑
摘要: 1.计算组合数:一般常用C(n+1,k)=(n+1)!/k!/(n+1-k)!来计算组合数,但是这个方法中涉及到阶乘运算,数据n不能太大。用下面的方法则可以避免这个问题。帕斯卡恒等式为C(n+1,k)=C(n,k-1)+C(n,k)#include <stdio.h>#include <stdlib.h>void error(){printf("Something is wrong,Please check it!");exit(1);}int fun(int n,int m){ if(n<0||m<0) error(); if(n< 阅读全文
posted @ 2012-02-22 23:21 某某。 阅读(616) 评论(0) 推荐(0) 编辑
摘要: 题目描述统计每个元音字母在字符串中出现的次数。输入输入数据首先包括一个整数n,表示测试实例的个数,然后是n行长度不超过100的字符串。输出对于每个测试实例输出5行,格式如下:a:num1e:num2i:num3o:num4u:num5多个测试实例之间由一个空行隔开。请特别注意:最后一块输出后面没有空行:)示例输入2aeioumy name is ignatius示例输出a:1e:1i:1o:1u:1a:2e:1i:3o:0u:1#include<stdio.h> #include<stdlib.h> #include<string.h> void main( 阅读全文
posted @ 2012-02-22 23:18 某某。 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 这道题我们有2种解法,一种解法有时候用GCC交的话会超时,而另一种诗运用了哈希查找的方法,者不得不说我们的崔哲崔老师很厉害。题目题目描述In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he made the following conjecture:Every even number greater than 4 can bewritten as the sum of two odd prime numbers.For example:8 阅读全文
posted @ 2012-02-22 23:17 某某。 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 有时候很多题目数值很大,这时候就很可能在内部存在着某种规律,比如这道题就存在着一个18循环的规律。。。。HDU-1163Eddy's digital RootsProblem DescriptionThe digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains t 阅读全文
posted @ 2012-02-22 23:13 某某。 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 哈希查找并不是一个太难的算法。主要思想(个人认为)是将输入的数据与下标产生直接的关系;第一步,让数组元素全部为零;第二部,输入数据,并建立数据与数组元素的关系,建立直接关系;第三步 查找题目描述有一个数据字典,里面存有n个数字(n<=100000),小明现在接到一个任务,这项任务看起来非常简单——给定m个数字,分别查询这m个数字是否出现在字典之中;但是考虑到数据量的问题,小明找到了善于编程的你,希望你可以帮他解决这个问题。输入输入数据只有一组!第一行包含两个整数n m,分别代表字典中数字的个数和要查询的数字的个数。接着n行代表字典中的n个数字。最后m表示要查询的数字。输出如果某个数字存在 阅读全文
posted @ 2012-02-22 23:11 某某。 阅读(514) 评论(0) 推荐(0) 编辑