文章列表
 
您正在查看 "笔记" 分类下的文章

2010-02-01 22:04

// 这题容易想到用映射容器 不过可以通过找规律找到循环的周期那样就很省时间了

#include <iostream>

#include <map>

using namespace std;

 
2010-01-31 11:45

//三维排序问题,根据选择不同选用不同的主序。

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
struct Book
{
string name;
int Year;
int Price;
};

//name为主序
bool CompName(const Book &b1, const Book &b2)
{
if(b1.name!=b2.name) return b1.name < b2.name;
else if(b1.Year!=b2.Year) return b1.Year < b2.Year;
else
 

 
2010-01-31 10:02

//最近学习STL时期,才发现它是如此的好用啊。

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    //freopen("in.txt","r",stdin);
string sa, sb, st;
vector<int>v;
int a, b, sum;
int p= 0;
int u= 0;
cin>>sa;
while (cin>>sa>>sb)
{
 

 
2010-01-30 22:28
用string对象s与一个字符串"aaa"相比较是否相等,不能用if(s.c_str()=="aaa") 得用if(s=="aaa")才行。
 
2010-01-29 22:21

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <IOMANIP>
using namespace std;
struct student
{
    string s;
    double d;
};
bool mycomp(const student &s1, const student &s2)
{
    if(s1.d!=s2.d) return s1.d > s2.d;
    if(s1.s!=s2.s) return s1.s < s2.s;

 
2010-01-29 21:56

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool comp(const string &s1, const string &s2)
{
    return s1.length()!=s2.length()?s1.length() <s2.length():s1<s2;
}
int main(int argc, char *argv[])
{
    ifstream cin("in.txt");
    vector<string>v;
 

 
2010-01-28 18:10

Description:

将01串首先按长度排序,长度相同时,按1的个数多少进行排序,1的个数相同时再按ASCII码值排序。

Input:

输入数据中含有一些01串,01串的长度不大于256个字符。

Output:

重新排列01串的顺序。使得串按基本描述的方式排序。

Sample Input:

10011111
00001101
1010101
1
0
1100

Sample Output:

0
1
1100
1010101
00001101
10011111

#include <iostream>
#include <fstream>
#include <stri

 
2010-01-28 11:34

找出输入数据中所有两两相乘的积为12!的个数。

Input:

输入数据中含有一些整数n(1≤n<2^32)。

Output:

输出所有两两相乘的积为12!的个数。

Sample Input:

1 10000 159667200 9696 38373635
1000000 479001600 3

Sample Output:

2
//用set实现,可以实现二分查找。
#include <iostream>
#include <set>
using namespace std;
int main()
{
    int num = 0;
 
 
2010-01-28 10:25

//推测完数为偶数(因为因子是成对的)

#include <iostream>
#include <vector>
using namespace std;
int main()
{
    vector<int>a;
    for (int i=2; i<10000; i+=2)
    {
        int sum=1;
        for (int j=2; j<=i/2; j++)
        {
     

 
2010-01-28 0:18
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string s;
int main()
{
int n;
while(cin>>n)
{
   if(n==0)
   {
    cout<<"          0-->0\n";
    continue;
   }
   s = "";
   for (int a = n; a; a=a/2) //存在s中
 
2010-01-27 23:11

两数的最大公约数:

int gcd1(int x, int y) //辗转相减压法
{
while(x!=y)
{
   if(x>y)
    x-=y;
   else
    y-=x;
}
return x;
}
int gcd2(int x, int y)//辗转取余法
{
int t;
while(x)
{  
       t = y%x;
    y = x;
    if(t==0)
     return x;
 

 
 
   
 
 
文章存档
 
     
 
最新文章评论
  

条理很清晰
 

什么是多重队列?跪求!!!
 

orz ...
 

请问这个代码,错在什么地方了?一直是 running time error 我是不是少考虑了什么条
 

#include<iostream> #include<algorithm> #include<string.h> using namespace std;
   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu