青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

newplan

阿基米德在洗澡時發(fā)現(xiàn)浮力原理,高興得來不及穿上褲子,跑到街上大喊:Eureka(我找到了)。
posts - 39, comments - 26, trackbacks - 0, articles - 4
  C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理



/*
 STL       map應用 
 
* Greedy   部分背包問題 
 
* newplan  開發(fā)時間:08.5.13  
*/
/*--------INCLUDES----------*/ 
#include 
<cstdlib>
#include 
<iostream>
#include 
<map>
#include 
<fstream> 
#include 
<iomanip>
/*--------INCLUDES----------*/ 

/*---------MACROS-----------*/
#define INPUTFILE  
"bag.txt"
/*---------MACROS-----------*/

/*----------STD-------------*/
using std::ifstream;
using std::cout;
using std::endl;
using std::map;
using std::greater;
using std::ios;
using std::setw;
/*----------STD-------------*/

/*-------GLOBAL VAL---------*/
ifstream  Fin;
int n;
int W;
int totalValue;
/*-------GLOBAL VAL---------*/

/*---------MAIN-------------*/
int main(int argc, char *argv[])
{  
 
    map
<int,int,greater<int> > goods;
    
    Fin.open(INPUTFILE);
 
    
int value;
    
    
int weight;
    
    Fin
>>W;
    
    Fin
>>n;
    
    
int i;
    
for(i=0;i<n;i++)
    {
       Fin
>>value;
       Fin
>>weight;
       goods[value]
=weight;
    }

    
for(map<int,int>::iterator it = goods.begin();it!=goods.end();it++)
    {
     cout
<<setiosflags(ios::left)<<"value:"<<setw(4)<<it->first
     
<<" weight:"<<setw(4)<<it->second<<endl;
    }
    
    
for(map<int,int>::iterator it = goods.begin();it!=goods.end();it++)
    {
      
if(W-it->second>=0)
      {
         W
-=it->second;
         totalValue
+=it->first*it->second;
         cout
<<"w="<<W<<" ";
      }
      
else 
      {
         totalValue
+=W*it->first;
         cout
<<"totalValue:"<<totalValue<<endl;
         break;  
      }
      
    }
    
    system(
"PAUSE");
    return EXIT_SUCCESS;
}
/*---------MAIN-------------*/
BAG.TXT
100   10
3   43
5   22
6    4
4   67
2    3
45  2
4   2
42  24
41  4
34  55

posted @ 2008-05-13 17:17 山泉彎延 閱讀(434) | 評論 (0)編輯 收藏

vc  :
  CMD:
  1. vcvars.bat    
  2. cl  /FAs  ***.cpp  注意要將VC98/bin下面的文件VCVARS.BAT帶到 所要編譯的CPP文件所在的文件夾之下


borlandc:
  1.設置環(huán)境變量右擊我的電腦進入高級環(huán)境進行系統(tǒng):path的設置:加入*\Borland\BCC55\BIN;
  2.在*\BIN文件夾下添加兩個文件bcc32.cfg 文件內容為:
  -I "*\Borland\BCC55\INCLUDES"
  -L "*\BORLAND\BCC55\LIBS"
  另外的一個文件名為:ilink32.cfg:
  -L "*\BORLAND\BCC55\LIBS"
   3.CMD:
   BCC32  -S *CPP/C

gcc/g++:gcc for c file  and g++ for cpp 只要安裝了DEVCPP就可以使用g++/gcc
   gcc  -S *c
   g++   -S *cpp
    
      

posted @ 2008-05-11 16:22 山泉彎延 閱讀(538) | 評論 (0)編輯 收藏

#include <functional>
#include 
<vector> 
#include 
<algorithm>
#include 
<iostream>


using namespace std;

class out_times_x 
{
private:
  
int multiplier;
  
public:
         
  out_times_x(
const int& k) : multiplier(k) { }
  
  void operator()(
const int& x) { cout << x * multiplier << " " << endl; }
  
};




int main ()
{
  
int sequence[5= {1,2,3,4,5};  
  
  vector
<int>  v(sequence+0, sequence+5);
  
  out_times_x f2(
2);
  
  for_each(v.begin(),v.end(),f2);   
// Apply function

  system(
"pause");
  
  return 
0;
}

posted @ 2008-05-11 11:47 山泉彎延 閱讀(4300) | 評論 (0)編輯 收藏

 win32:DEV C++ 格式:
  #include 
<iostream>
  using namespace std;
  

        
int a=1;/*a,b 應當都是全局的*/
        
int b=10;

  
int main(int argc,char **argv)
  {
         cout
<<sizeof(int)<<endl;
         
         
/*AT&T 規(guī)范 Not Intel*/
         __asm(
"mov _b,%eax");//mov 的左邊是源,右邊是目標 
         
         __asm(
"mov %eax,_a");

         cout
<<a<<endl;
         
         cout
<<b<<endl;
         
         cout
<<"a+b="<<a+b<<endl;
         
         getchar();
         
         return(a
-b);
  }
win32:VC6.0格式:
#include 
<iostream>
using namespace std;
int main(int argc,char **argv)
{
        
/*int的長度和eax的長度一樣都是4個字節(jié)*/
        cout
<<sizeof(int)<<endl;
        
int a=100;
        
int b=10;
        
/*Intel 規(guī)范*/
         __asm{
          mov eax,a;
//eax 是目標,a 是源
          add eax,b;
          mov a,eax;
              }
         cout
<<a<<endl;
         cout
<<"a+b="<<a<<endl;
         return(a
-b);
}

posted @ 2008-05-10 17:54 山泉彎延 閱讀(543) | 評論 (0)編輯 收藏

#include <iostream>
#include 
<queue>//有priority_queue
using namespace std;  
class cl
{
      
public:
             
int i;
             
};
bool operator
>(const cl&a, const cl & b)
{
     return a.i 
< b.i;    
}
bool operator
<(const cl&a,const cl &b)
{
     return a.i
>b.i;
}
int main()
{
    
    
    priority_queue
<cl,vector<cl>,greater<vector<cl>::value_type> > q;
    cl a;
    
while(cin>>a.i)
    {
        q.push(a);
    }
    
while(!q.empty())
    {
        cout
<<q.top().i<<endl;
        q.pop();
    }
    system(
"PAUSE");
    return 
1;
}

posted @ 2008-05-07 15:26 山泉彎延 閱讀(323) | 評論 (0)編輯 收藏

/*
Romberg Algorithm 
開發(fā)者:newplan
開發(fā)日期:
08.05.07 
*/


/*=======================================*/
/*INCLUDES*/ 
#include           
<cstdlib>
#include           
<iostream>
#include           
<cmath>
/*=======================================*/
/*MACROS  USED IN THIS FILE*/
#define            MAX       
20   
#define            PRECISION 
0.000008
/*=======================================*/
/*DECLARE NAMES IN STL NAMESAPCE */
using  std::cout;
using  std::endl;

/*=======================================*/
/*CLASS FUNC (FUNCTION OBJECT): THE ORIGINAL FUNCTION WE WANT TO INTEGRAL*/
class  func{
       
public:
              func(
double x=1.0):exp(x){}
              
double operator()(const double& dnum)const{return pow(dnum,exp);}
       
private:
              
double exp;
       };
/*=======================================*/
/*CLASS ECHELONFUNC (FUNCTION OBJECT)梯形法的遞推公式*/
class  echelonFunc{
       
public:
              echelonFunc(
double begining,double ending,func & myfunc);
              
double operator()();
       
private:
               
double    h;
               
int       n;
               
double    T;
               func      myfunc;
               
double    begining;
               
double    ending ;
     };
/*=======================================*/
echelonFunc::echelonFunc(
double begining,double ending,func & myfunc)
              {
               this
->begining=begining;
               this
->ending=ending;
               this
->h=ending-begining;
               this
->n=0;
               this
->T=0;
               this
->myfunc=myfunc;//FUCNTION 
              }
/*------------------------------*/
/* INCREASE FUNCTION 遞推函數*/
double echelonFunc::operator()()
              {   
if(this->n==0)
                  {
                   this
->T=h*0.5*(myfunc(this->begining)+myfunc(this->ending));
                   this
->n=1;
                   return this
->T;
                  }
                  
double len=0.5*h;
                  
double sum=0;
                  
int k=0;
                  
for(k=0;k<this->n;k++)
                      {
                       sum
+=myfunc(len);
                       
len=len+h;
                      }
                  this
->T=0.5*this->T+0.5*h*sum;
                  this
->h/=2;
                  this
->n*=2;
                  return this
->T;
              }
/*=======================================*/
/*THE MAIN CLASS IN THIS PROGRAM*/ 
class  Romberg{
       
public:
              Romberg(
double begining,double ending,double exp);
              ~Romberg();
       
private:
              void RombergCPU();
/*THE MOST IMPORTANT FUNCTION IN THIS PROGRAM*/
              echelonFunc 
*echol; 
              
double T[MAX][MAX];/*STO THE ROMBERG TABLE*/       
       };
/*------------------------------*/
Romberg::Romberg(
double begining ,double ending ,double paraexp)
{
    func     myfunc(paraexp);
    echol 
=  new echelonFunc(begining,ending,myfunc);
    RombergCPU();
}
/*------------------------------*/
Romberg::~Romberg()
{
     delete echol;
}
/*------------------------------*/
void Romberg::RombergCPU()
{   clock_t Start; 
//TIME STARAT
    clock_t 
End;   //TIME END
    
double *p[MAX];//WE USE THIS POINTER ARRAY TO ACCELERATE ALGOTITHM
    
double **q;
    
int i,j;
    Start 
= clock();//TIME START FROM HERE
    
for(i = 0,q = p; q < p+MAX; q++,i++)
        
*q= &T[i][0];
    
double a,b,pows; 
    cout
<<"-----------------------Romberg Algorithm---------------------"<<endl;
    
*p[0]=(*echol)();
    cout
<<"  "<<*p[0]<<endl;
    p[
0]++;
    
do{
       
*p[0]=(*echol)();
        cout
<<"  "<<*p[0];
        p[
0]++;
        
for(i=1;;i++)
                  {
                    pows
=pow(4.0,double(i));
                    a
=pows/(pows-1);
                    b
=1/(pows-1);
                    
*p[i]=a*(*(p[i-1]-1))-b*(*(p[i-1]-2));//ROMBERG ALGORITHM
                    cout
<<"  "<<*p[i];
                    
if(p[i]==&T[i][0])
                      {
                      p[i]
++
                      break;
                      } 
                     p[i]
++;
                   }
                   cout
<<endl;//fabs(T[i][0]-T[i-1][0])
       }
while(fabs(T[i][0]-T[i-1][0])>PRECISION);
    
    
End = clock();//TIME END HERE
    
    cout
<<"-------------------------------------------------------------"<<
    endl
<<"  TIME SPEND:"<<(double)(End-Start)/CLOCKS_PER_SEC<<endl; 

/*=======================================*/
/*MAIN FUNCTION*/
int main(int argc, char *argv[])
{  
   Romberg  romberg(
0,1,1.5);//ROMBERG API :BEGIN(0END(1EXP(1.5)
   system(
"PAUSE");
   return EXIT_SUCCESS;
}

posted @ 2008-05-07 15:05 山泉彎延 閱讀(1511) | 評論 (1)編輯 收藏

/*
 *用來測試STL hash_map 
 *簡單例子2008.5.5
*/
#include  
<cstdlib>
#include  
<iostream>
#include  
<string>
#include  
<hash_map.h>/*因為hash_map暫不為CPP標準所以沒辦法寫為<hash_map>*/
/*-------------------------------------------*/
using  std::cout;
using  std::endl;
using  std::string;
/*-------------------------------------------*/
/*函數類
 *作為hash_map的hash函數 
 *string沒有默認的hash函數 
 
*/ 
class str_hash{
      
public:
       size_t 
operator()(const string& str) const
        {
                unsigned 
long __h = 0;
                
for (size_t i = 0 ; i < str.size() ; i ++)
                __h 
= 5*__h + str[i];
                
return size_t(__h);
        }
};
/*-------------------------------------------*/
/*函數類 
 *作為hash_map的比較函數 )
 *(查找的時候不同的key往往可能對用到相同的hash值
*/ 
class str_compare
{
      
public:
             
bool operator()(const string& str1,const string& str2)const
             {
return   str1==str2;}
};
/*-------------------------------------------*/
int 
main(
int argc, char *argv[])
{  
    hash_map
<string,string,str_hash,str_compare>  myhash;
    
    myhash[
"google"]="newplan";
   
    myhash[
"baidu"]="zhaoziming";
   
    
if(myhash.find("google")!=myhash.end())
      cout
<<myhash["google"]<<endl;
    
    system(
"PAUSE");
    
    
return EXIT_SUCCESS;
}
/*-------------------------------------------*/

posted @ 2008-05-05 17:17 山泉彎延 閱讀(14564) | 評論 (6)編輯 收藏

#include <stdio.h>
#include <ctype.h>

int lookahead;
void error()
 {
     printf("synatax error\n"); 
  exit(1);
 }
 void match(int t)
 {
     if(lookahead==t)
       lookahead=getchar();
  else
     error();
  }
 
  void term()
  {
       if(isdigit(lookahead))
          {
         putchar(lookahead);
         match(lookahead);
          }
          else error();
   }
   void exptr()
   {
     term();
     while(1)
     {
     if(lookahead=='+')
     {
           match('+');term();putchar('+');
          
       }
       else if(lookahead=='-')
     {
           match('-');term();putchar('-');
          
       }
       else  break;
   }
    }
int main(int argc, char *argv[])
{
  lookahead=getchar();
  exptr();
  putchar('\n');
  system("PAUSE"); 
  return 0;
}

posted @ 2008-03-26 09:40 山泉彎延 閱讀(1185) | 評論 (1)編輯 收藏

#include "apue.h"
#include 
"semaphore.h"
#include 
"pthread.h"

#define N 
5
static 
int necs;
static sem_t  
*forks;

void 
*
takeFork(
int i)
{
if(i==N-1)
    {
     sem_wait(
&forks[0]);
     sem_wait(
&forks[i]);
    }
   
else
     {
     sem_wait(
&forks[i]);
     sem_wait(
&forks[i+1]);
     }
}
void 
*
putFork(
int i)
{
if(i==N-1)
    {
     sem_post(
&forks[0]);
     sem_post(
&forks[i]);
    }
else
    {
    sem_post(
&forks[i]);
    sem_post(
&forks[i+1]);
   }
}
void 
thinking(
int i,int necs)
{
    printf(
"pholosopher %d  is thinking\n",i);
    sleep(necs);

}
void
eating(
int i,int necs)
{
    printf(
"pholosopher %d  is eating\n",i);
    sleep(necs);
}
void 
*
philosopher(void 
*n)
{
    
int i=(int )n;
    
while(1)
    {
     thinking(i,necs);
     takeFork(i);
     eating(i,necs);
     putFork(i);
    }
}
//============================main function
int
main(
int argc,char *argv[])
{
   pthread_t tid;
  
   
if(argc==1)
          necs
=2;
   
else if(argc ==2)
          necs
=atoi(argv[1]);
   
else return 1;
  
   forks
=(sem_t*)malloc(N*sizeof(sem_t));
   
   
int i;
   
for(i=0;  i<N;  i++)
   sem_init(forks
+i,0,1);

   
int status;
   
for(i=0;i<N;i++)
    {
      status
=pthread_create(&tid,NULL,philosopher,(void*)i);

      
if(status<0)
      err_sys(
"create error!");  
    } 
    pthread_join(tid ,
NULL);
    return 
0;  
}

posted @ 2008-01-04 00:14 山泉彎延 閱讀(355) | 評論 (0)編輯 收藏

#include "apue.h"
#include 
"lock.h"
#include 
"lock.c"

/*define some important variable*/
/*=======================================*/
pid_t  pid;

static char 
*forks[5]={
"fork0""fork1""fork2" ,"fork3" ,"fork4"
};

static 
int necs;

#define N 
5

/*======================================*/
void takeFork(
int i)
{
if(i==N-1)
  {
     lock(forks[
0]);
     lock(forks[i]);
  }
else
{
lock(forks[i]);
lock(forks[i
+1]);
}
}


void putFork(
int i)
{
   
if(i==N-1)
    {
    unlock(forks[
0]);
    unlock(forks[i]);
    }
  
else
   {
   unlock(forks[i]);
   unlock(forks[i
+1]);

   }
}
int
thinking(
int i,int necs){
printf(
"pholosopher %d is thinking\n",i);
return sleep(necs);
}
int 
eating(
int i,int necs)
{printf(
"pholosopher %d is eating\n",i);
return sleep(necs);
}
void philosopher(
int i)
{
while(1)
{
thinking(i,necs);
takeFork(i);
eating(i,necs);
putFork(i);

}
}
int
 main(
int argc ,char *argv[])
{
 
if(argc=1)
      necs
=2;
else if(argc==2)
     necs
=atoi(argv[1]);
else  return 0;
 
int i;   
for(i=0;i<N;i++)
{
 pid
=fork();
 
if(pid ==0)
     philosopher(i);
}
return 
0;
}

posted @ 2008-01-04 00:13 山泉彎延 閱讀(290) | 評論 (0)編輯 收藏

僅列出標題
共4頁: 1 2 3 4 
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美主播一区二区三区| 久久成人18免费网站| 久久视频一区| 亚洲国产欧美日韩| 亚洲午夜久久久久久尤物 | 一区二区高清| 亚洲午夜女主播在线直播| 欧美在线一级视频| 亚洲精品一二三| 久久精品亚洲热| 国产视频在线一区二区| 亚洲视频一区在线| 亚洲精华国产欧美| 免费欧美日韩| 在线观看亚洲专区| 亚洲香蕉网站| 亚洲欧洲日产国产综合网| 免费黄网站欧美| 亚洲国产精品嫩草影院| 性欧美videos另类喷潮| 日韩亚洲欧美精品| 欧美久久精品午夜青青大伊人| 亚洲福利视频一区二区| 久久综合久色欧美综合狠狠| 性视频1819p久久| 国产欧美va欧美不卡在线| 亚洲午夜一二三区视频| 亚洲精品孕妇| 欧美日韩综合在线免费观看| 夜夜嗨av一区二区三区网页| 91久久在线视频| 亚洲午夜激情网页| 国产精品永久免费| 午夜欧美精品久久久久久久| 一区二区在线免费观看| 老妇喷水一区二区三区| 久久人人爽人人爽| 亚洲第一精品电影| 亚洲国产日日夜夜| 欧美激情精品久久久六区热门| 亚洲精品一级| 99热精品在线| 欧美午夜精品理论片a级按摩| 亚洲一区久久久| 亚洲欧美另类中文字幕| 国内精品免费在线观看| 另类欧美日韩国产在线| 久久亚洲春色中文字幕久久久| 在线成人免费视频| 亚洲精品国产精品乱码不99按摩| 欧美日韩一区二区在线观看| 亚洲综合第一页| 久久精品国产91精品亚洲| 亚洲国产精品一区二区第四页av| 亚洲国产你懂的| 欧美视频二区| 欧美视频中文字幕| 久久精品亚洲一区二区| 噜噜噜噜噜久久久久久91| 在线成人免费观看| 一区二区三区www| 国产日韩欧美不卡在线| 亚洲国产另类 国产精品国产免费| 欧美fxxxxxx另类| 久久成人一区二区| 欧美精品激情在线观看| 午夜精品在线看| 欧美成人一品| 久久国产精品免费一区| 欧美激情在线观看| 国产欧美日韩专区发布| 亚洲国产欧美在线人成| 国产亚洲成精品久久| 欧美sm视频| 亚洲福利在线视频| 久久精品夜色噜噜亚洲a∨ | 日韩一级在线| 一区免费观看视频| 欧美一二三区精品| 久久久国产精品一区二区中文| 欧美亚州在线观看| 亚洲欧美视频在线| 蜜桃av一区二区三区| 在线精品视频一区二区| 美日韩精品视频| 亚洲三级网站| 亚洲欧美成人精品| 国产欧美一区二区在线观看| 久久蜜桃香蕉精品一区二区三区| 久久精品国产综合精品| 伊人精品久久久久7777| 欧美国产成人精品| 亚洲欧美激情四射在线日 | 亚洲一区精品电影| 国产一区91| 欧美精品一区二区三区在线播放 | 一区二区三区欧美在线| 国产精品卡一卡二卡三| 久久精品国产精品 | 亚洲视频在线观看免费| 久久夜色精品亚洲噜噜国产mv | 亚洲乱码一区二区| 浪潮色综合久久天堂| 一本到12不卡视频在线dvd| 久久精品视频在线免费观看| 久久资源av| 亚洲精品美女91| 国产精品一区二区久久| 欧美成年人在线观看| 午夜视频一区二区| 亚洲日本激情| 蜜臀av国产精品久久久久| 亚洲一区自拍| 亚洲大胆av| 欧美一区永久视频免费观看| 99精品热视频| 亚洲国产精品久久| 国产一区二区三区丝袜| 国产精品v欧美精品v日韩精品| 久久久久久久久蜜桃| 亚洲午夜三级在线| 亚洲精品国产品国语在线app | 一区二区三区欧美激情| 精品动漫3d一区二区三区免费 | 美女脱光内衣内裤视频久久网站| 欧美精品一区二区三区蜜臀| 久久精品人人做人人综合| 亚洲深夜福利在线| 欧美高清在线一区| 麻豆精品一区二区av白丝在线| 亚洲影院高清在线| 一本色道久久综合亚洲精品不卡| 亚洲国产婷婷香蕉久久久久久| 国产一区二区三区观看| 国产精品久久久久久久久久久久| 欧美精品色网| 欧美日韩国产成人在线免费 | 日韩视频在线观看一区二区| 欧美激情视频网站| 欧美成人一区二免费视频软件| 久久全国免费视频| 麻豆成人在线| 久久综合九色九九| 久久一区亚洲| 国产精品视频久久| 亚洲国产老妈| 国产精品wwwwww| 亚洲国产精品一区二区尤物区| 夜夜精品视频| 91久久在线视频| 亚洲国产精品成人久久综合一区| 欧美h视频在线| 亚洲丶国产丶欧美一区二区三区| 欧美r片在线| 亚洲欧洲在线一区| 一本色道久久加勒比88综合| 中文在线资源观看网站视频免费不卡| 亚洲欧洲在线免费| 亚洲图片激情小说| 午夜精品久久久| 久久人人97超碰国产公开结果| 久久亚洲国产精品日日av夜夜| 欧美成人久久| 欧美日韩综合不卡| 国产日韩综合一区二区性色av| 精品动漫一区二区| 最新成人av在线| 亚洲一区国产视频| 欧美在线网站| 一区二区三区日韩在线观看| 欧美日韩美女| 午夜精品久久久久久久久久久久久 | 亚洲制服欧美中文字幕中文字幕| 欧美一区二区免费观在线| 久久久久国产一区二区三区四区 | 亚洲小少妇裸体bbw| 欧美一区二区大片| 欧美国产精品一区| 亚洲一二三四久久| 欧美凹凸一区二区三区视频| 国产精品久久久久久久久动漫| 一区视频在线看| 亚洲欧美国产另类| 欧美高清视频在线 | 久久免费观看视频| 亚洲精品美女| 国产午夜精品在线| 欧美日精品一区视频| 国产精品日韩专区| 亚洲国产精品美女| 亚洲午夜久久久久久久久电影院 | 亚洲视频在线观看视频| 麻豆成人在线| 国产亚洲精品自拍| 亚洲午夜久久久| 亚洲国产欧美不卡在线观看| 亚洲欧美在线免费| 国产精品igao视频网网址不卡日韩| 在线观看日韩av先锋影音电影院| 亚洲欧美日韩国产一区二区|