OJ
迎仔
Do before say sth
More pains ,more gains
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
题目1153:括号匹配问题
运用String类#include#include#includeusing namespace std; string str;//接收最初字符串string ans;//保存最终字符串stack S;//初始化堆栈 int main(){ while(cin >> str) { ans = str;//为ans也分配这么大空间原创 2014-03-28 12:04:21 · 688 阅读 · 0 评论 -
题目1023:EXCEL排序
#include#include#includeusing namespace std; typedef struct Student{ string id;//学号 string name; //姓名 int grade; // 成绩}Stu;Stu students[100000]; bool cmpId(Stu a, Stu b){ ret原创 2014-03-25 11:14:54 · 726 阅读 · 0 评论 -
题目1433:FatMouse
#include#include//#include#includeusing namespace std; typedef struct JavaBean{ double J;//房间中的javaBean数目 double F;//需要猫食 double weight;//J/F 权重}JB;JB javaBean[1000];bool cmp(cons原创 2014-03-26 09:55:30 · 662 阅读 · 0 评论 -
题目1156:谁是你的潜在朋友
Hash算法#includeusing namespace std; int book[201]={0};//初始化了201个int person[1000];int main(){ int N;//N个读者N>=2 int M;//M本书依次编号1,2,……M int i; int j; while(cin >> N >> M) {原创 2014-03-26 16:41:37 · 573 阅读 · 0 评论 -
题目1052:找x
#include using namespace std; int num[200];//存储n个数 //查找x返回下标,失败返回-1int findx(int x,int n){ int i; for(i=0; i<n; i++) { if(num[i] == x) { return i;原创 2014-03-27 00:12:29 · 765 阅读 · 0 评论 -
题目1431:Sort
#include#includeusing namespace std; bool cmp(const int a, const int b){ return a >b;} int nums[1000000]; int main(){ int n;//n个不同数 int m;//输出m大数 int i,j; while(cin >>原创 2014-03-26 08:13:18 · 638 阅读 · 0 评论 -
题目1069:查找学生信息
#include#include#includeusing namespace std; class Student{public: string id;//学号 string name;//名字 string sex;//性别 int age;//年龄 bool operator <(const Student&A)const {原创 2014-03-27 00:56:41 · 778 阅读 · 0 评论 -
题目1018:统计同成绩学生人数
#include using namespace std; void match(int grade[],int N,int score,int &cnt){ int i =0; cnt =0; for(i =0; i< N; i++) { if(score == grade[i]) { cnt ++原创 2014-03-26 08:03:19 · 714 阅读 · 0 评论 -
题目1088:剩下的树
Hash算法#includeusing namespace std; int length[10001];//记录马路每个整数点处有无树 //用来初始化道路两旁的树void initLoad(int L){ int i; for(i =0; i<=L; i++) { length[i] =1; }} //去掉begin和end原创 2014-03-26 17:12:12 · 520 阅读 · 0 评论 -
题目1065:输出梯形
#includeusing namespace std; int main(){ int h;//记录梯形高度 int i; int j; while(cin >> h) { for(i =0 ; i <h; i++) { //输出空格 for(j=h+2*(h-1);j原创 2014-03-26 19:30:50 · 726 阅读 · 0 评论 -
题目1054:字符串内排序
#include#include#includeusing namespace std; //全局变量char str[200]; int main(){ while(cin >> str) { sort(str,str+strlen(str)); cout << str << endl; } retur原创 2014-03-25 12:14:39 · 665 阅读 · 0 评论 -
题目1070:今年的第几天?
#include using namespace std; #define ISLEAP(x) (0==x%4 && 0!= x%100)|| (0==x%400) >0?1:0 int monthOfDay[13][2]={ 0,0, 31,31, 28,29, 31,31, 30,30, 31,31, 30,30,原创 2014-03-25 19:32:45 · 717 阅读 · 0 评论 -
题目1467:二叉排序树 (非递归与递归)
//非递归实现二叉排序树#includeusing namespace std;struct Node{ Node *lchild; //做孩子 Node *rchild; //右孩子 int value;};//创建节点void createNode(Node *&p, int x){ Node *root = p; Node *pre; //创建根节点 i原创 2014-03-31 19:12:26 · 720 阅读 · 0 评论 -
最长公共子序列算法
经典算法题每日演练——第四题 最长公共子序列 最长公共子序列的问题常用于解决字符串的相似度,是一个非常实用的算法,作为码农,此算法是我们的必备基本功。 举个例子,cnblogs这个字符串中子序列有多少个呢?很显然有27个,比如其中的cb,cgs等等都是其子序列,我们可以看出子序列不见得一定是连续的,连续的那是子串。 我想大家已经了转载 2014-04-01 11:33:38 · 788 阅读 · 0 评论 -
题目1474:矩阵幂
#includeusing namespace std; int matrix[10][10];//用大数组来记录矩阵int result[10][10];//用来记录计算结果矩阵int tmpResult[10][10];//输入矩阵void colect(int &n){ int i= 0; int j= 0; for(i =0 ;i < n; i++)原创 2014-04-01 16:15:42 · 854 阅读 · 0 评论 -
题目1178:复数集合
#include#include#include#include#includeusing namespace std; struct complex{ int a; int b; bool operator <(const complex &cA)const //要有返回值 { int mx = a*a +b*b;原创 2014-04-02 09:22:39 · 713 阅读 · 0 评论 -
题目1169:比较奇偶数个数
#include#includeusing namespace std; //int nums[1001];//记录输入的数字int m;//记录偶数个数int n;//记录奇数个数 int main(){ int t; int tmp;//记录临时数据 //ifstream cin("BUPT_1169.txt"); while(cin >> t原创 2014-04-02 10:06:08 · 744 阅读 · 0 评论 -
题目1170:找最小数
#include#include//#includeusing namespace std; struct NewNum{ int x; int y; bool operator <(const NewNum & anum)const { if(x == anum.x) { return y < an原创 2014-04-02 10:20:13 · 767 阅读 · 0 评论 -
题目1043:Day of Week
#include#include#includeusing namespace std; #define ISYEAR(x) ((x%100 !=0 && x%4 ==0)|| (x%400==0))?1:0 int dayOfMonth[13][2]={ 0,0, 31,31, 28,29, 31,31, 30,30, 31,31,原创 2014-03-25 18:38:59 · 658 阅读 · 0 评论 -
题目1096:日期差值
#include#includeusing namespace std; #define ISYEAR(x) (x%100 !=0 && x%4 ==0)|| x%400==0?1:0 int dayOfMonth[13][2]={ 0,0, 31,31, 28,29, 31,31, 30,30, 31,31, 30,30,原创 2014-03-25 15:35:29 · 683 阅读 · 0 评论 -
题目1186:打印日期
#include#includeusing namespace std; #define ISLEAP(x) (0== x%4 && 0!= x%100)||(0==x%400)>0?1:0 int dayOfMonth[13][2]={ 0,0, 31,31, 28,29, 31,31, 30,30, 31,31, 30,30原创 2014-03-25 20:08:38 · 704 阅读 · 0 评论 -
题目1434:今年暑假不AC
#include#includeusing namespace std; class MyTime{public: int begin; //开始时间 int end; //结束时间 bool operator <(const MyTime &timeA)const //此处const丢了 { return this->end < time原创 2014-03-27 10:14:55 · 639 阅读 · 0 评论
分享