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

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>
            麻豆精品91| 欧美日韩色综合| 一区二区三区精品国产| 欧美一区二区视频观看视频| 亚洲天堂男人| 欧美日韩高清在线播放| 欧美r片在线| 国产一区深夜福利| 亚洲欧美一区二区精品久久久| 一区二区三区四区国产精品| 欧美第十八页| 欧美韩日精品| 亚洲人成在线观看网站高清| 久久尤物电影视频在线观看| 久久躁日日躁aaaaxxxx| 加勒比av一区二区| 久久久久国产精品一区| 免费久久99精品国产| 国内精品**久久毛片app| 欧美一站二站| 久久天天躁狠狠躁夜夜av| 国模私拍视频一区| 久久精品91| 欧美成人精品一区| 亚洲免费电影在线| 欧美日韩亚洲一区二区| 在线视频欧美日韩| 午夜免费电影一区在线观看| 国产欧美日韩亚州综合| 欧美一级免费视频| 乱码第一页成人| 亚洲精品国产精品国自产观看浪潮| 免费看亚洲片| 日韩视频在线观看| 性欧美videos另类喷潮| 狠狠色丁香久久婷婷综合丁香| 久久久99免费视频| 亚洲福利视频免费观看| 日韩亚洲欧美中文三级| 欧美日韩一区在线观看视频| 亚洲欧美日韩国产一区二区| 久久久久久久欧美精品| 亚洲福利视频一区| 欧美日韩另类视频| 亚洲欧美在线免费| 欧美国产欧美亚洲国产日韩mv天天看完整 | 美女任你摸久久| 日韩视频一区二区三区在线播放免费观看 | 国产精品中文在线| 久久久国产成人精品| 欧美韩国在线| 性欧美精品高清| 亚洲国产毛片完整版 | 亚洲国产成人在线播放| 亚洲在线播放电影| 精品av久久707| 欧美午夜宅男影院| 麻豆亚洲精品| 亚洲一区亚洲二区| 欧美国产专区| 久久精品在线免费观看| 日韩亚洲在线观看| 韩国一区二区三区美女美女秀| 欧美国产日韩一区| 久久国产精品99国产| 日韩亚洲国产精品| 你懂的视频一区二区| 午夜精品美女自拍福到在线| 91久久久久久久久| 国产主播一区| 国产精品久久毛片a| 欧美成人综合一区| 久久精品99国产精品| 在线中文字幕不卡| 亚洲国产综合在线| 久久这里只有精品视频首页| 香蕉久久一区二区不卡无毒影院 | 欧美91大片| 久久精品国产96久久久香蕉 | 中文精品视频| 亚洲每日在线| 亚洲激情在线播放| 黑人巨大精品欧美一区二区小视频 | 久久夜色精品国产亚洲aⅴ| 亚洲午夜视频| 一区二区91| 日韩一级大片在线| 亚洲精品激情| 亚洲欧洲一区二区三区| 欧美激情亚洲激情| 欧美大片免费久久精品三p| 久久久国产成人精品| 欧美亚洲三区| 欧美在线高清| 午夜在线视频观看日韩17c| 亚洲小视频在线观看| 国产精品99久久久久久www| 99热免费精品| 一区二区三区久久网| 在线一区观看| 亚洲在线免费观看| 性欧美video另类hd性玩具| 午夜精品免费在线| 久久国产精品99国产精| 久久精品一区二区三区不卡牛牛| 久久福利视频导航| 久久久久国产精品麻豆ai换脸| 久久精品国产一区二区三| 久久精品综合网| 久久综合久久久| 欧美电影免费观看大全| 亚洲二区在线观看| 99热免费精品在线观看| 亚洲一区二区在线| 欧美一区二区高清| 麻豆九一精品爱看视频在线观看免费| 美日韩精品视频| 欧美日韩成人综合在线一区二区| 欧美三日本三级三级在线播放| 国产精品日韩欧美一区二区三区| 国产九区一区在线| 在线国产亚洲欧美| 99在线|亚洲一区二区| 亚洲欧美日韩综合| 开心色5月久久精品| 亚洲成在人线av| 99日韩精品| 欧美在线亚洲| 欧美激情欧美狂野欧美精品| 欧美午夜不卡视频| 狠狠综合久久av一区二区老牛| 91久久精品www人人做人人爽 | 久久精品一二三| 亚洲国产欧美日韩精品| 亚洲一区免费| 美女精品视频一区| 国产精品综合网站| 亚洲人成网站精品片在线观看| 午夜日韩激情| 亚洲福利在线观看| 午夜精品久久久久影视| 欧美成人黑人xx视频免费观看| 国产精品免费一区豆花| 亚洲大胆av| 性欧美精品高清| 最新亚洲激情| 久久精品色图| 国产精品免费一区二区三区在线观看 | 精品动漫3d一区二区三区免费版| 99精品免费网| 久久综合狠狠综合久久激情| 一区二区三区黄色| 欧美大片免费观看| 国产一区二区成人| 亚洲一区综合| 亚洲韩国精品一区| 久久麻豆一区二区| 国产日韩欧美亚洲一区| 一区二区毛片| 亚洲国产成人精品女人久久久| 亚洲欧美国产视频| 欧美午夜精品久久久久久浪潮| 亚洲激情网址| 欧美成人日韩| 久久人体大胆视频| 国产在线拍偷自揄拍精品| 亚洲欧美日韩精品久久| 亚洲精品乱码久久久久久久久| 久久资源av| 狠狠入ady亚洲精品| 久久www成人_看片免费不卡| 国产精品99久久99久久久二8| 欧美高清视频一区二区| 亚洲国产精品电影| 美女尤物久久精品| 久久久久看片| 一区二区视频免费在线观看| 久久久久久久一区| 性娇小13――14欧美| 国产精品推荐精品| 欧美一区二区三区电影在线观看| 一本色道**综合亚洲精品蜜桃冫| 欧美精品偷拍| 在线亚洲精品| 一区二区三区成人精品| 欧美涩涩网站| 性欧美精品高清| 亚洲欧美日韩一区在线| 国产欧美午夜| 久久久夜夜夜| 久久五月激情| 亚洲精品国精品久久99热一| 亚洲第一在线综合网站| 巨胸喷奶水www久久久免费动漫| 亚洲国产毛片完整版| 欧美韩日高清| 欧美日韩美女| 久久av资源网站| 老司机精品视频一区二区三区| 亚洲精品免费一区二区三区|