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

newplan

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



/*
 STL       map應用 
 
* Greedy   部分背包問題 
 
* newplan  開發時間: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 山泉彎延 閱讀(435) | 評論 (0)編輯 收藏

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


borlandc:
  1.設置環境變量右擊我的電腦進入高級環境進行系統: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 山泉彎延 閱讀(539) | 評論 (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 山泉彎延 閱讀(4302) | 評論 (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 規范 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個字節*/
        cout
<<sizeof(int)<<endl;
        
int a=100;
        
int b=10;
        
/*Intel 規范*/
         __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 山泉彎延 閱讀(545) | 評論 (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 山泉彎延 閱讀(328) | 評論 (0)編輯 收藏

/*
Romberg Algorithm 
開發者:newplan
開發日期:
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 山泉彎延 閱讀(1518) | 評論 (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 山泉彎延 閱讀(14566) | 評論 (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 山泉彎延 閱讀(1190) | 評論 (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 山泉彎延 閱讀(358) | 評論 (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 山泉彎延 閱讀(294) | 評論 (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>
            久久成人人人人精品欧| 欧美日韩国产一区二区| 久久av一区二区三区漫画| 欧美精品一区二区三区很污很色的| 国产精品毛片va一区二区三区| 亚洲精品一区二区三区四区高清| 久久久久国色av免费观看性色| 日韩午夜精品| 欧美日韩1区2区3区| 亚洲精品一区在线观看| 亚洲第一精品夜夜躁人人爽| 性伦欧美刺激片在线观看| 国产精品免费久久久久久| 欧美一区三区三区高中清蜜桃| 午夜久久99| 国产精品一区二区三区四区五区| 午夜精品视频在线观看| 夜夜嗨av一区二区三区免费区| 欧美精品v日韩精品v国产精品 | 欧美日韩一区二区三区免费看| 亚洲高清在线| 男人插女人欧美| 噜噜噜91成人网| 日韩一区二区精品在线观看| 欧美成人精品福利| 日韩午夜剧场| 国产精品99久久久久久宅男| 国产精品午夜在线| 久久成人精品| 久久婷婷蜜乳一本欲蜜臀| 亚洲国产精品一区二区第一页| 欧美电影在线观看| 午夜精品久久久久久久久久久久久| 亚洲免费精彩视频| 一区二区三区四区国产| 国产免费亚洲高清| 麻豆精品视频在线观看| 欧美福利一区二区| 欧美一区二区三区视频免费| 久久精品视频在线看| 亚洲国产精品毛片| 一区二区三区精品视频在线观看| 国产精品视频网站| 欧美高潮视频| 国产欧美日韩高清| 亚洲福利小视频| 欧美日韩中文字幕| 国产一区二区三区奇米久涩| 美国十次了思思久久精品导航| 久久综合中文| 在线中文字幕日韩| 久久精品72免费观看| 99精品国产高清一区二区| 校园激情久久| 99精品视频免费观看| 久久成人久久爱| 亚洲欧洲av一区二区| 欧美~级网站不卡| 久久精品日韩| 欧美色视频日本高清在线观看| 久久亚洲免费| 国产精品欧美日韩一区| 亚洲国产激情| 韩国久久久久| 亚洲综合日韩| 亚洲图片你懂的| 你懂的成人av| 久久综合色综合88| 国产欧美一区二区精品仙草咪| 亚洲精品在线二区| 亚洲高清久久网| 久久精品国亚洲| 欧美一区二区久久久| 亚洲高清视频在线| 久久精品国产综合精品| 午夜精品99久久免费| 欧美精品国产精品日韩精品| 美日韩精品免费观看视频| 国产欧美精品一区| 中文在线资源观看视频网站免费不卡| 亚洲日本在线观看| 另类欧美日韩国产在线| 免费成人小视频| 国产在线视频欧美| 亚洲欧美日韩精品久久| 亚洲在线视频免费观看| 欧美日韩综合| 中文亚洲字幕| 久久超碰97人人做人人爱| 国产精品久久久久91| 亚洲视频一区在线| 午夜视频在线观看一区二区| 欧美日韩一区自拍| 一区二区三区久久久| 亚洲专区在线视频| 国产精品欧美经典| 亚洲欧美另类综合偷拍| 欧美综合77777色婷婷| 国产一区视频在线观看免费| 羞羞色国产精品| 久久人体大胆视频| 亚洲福利在线视频| 欧美精品日韩精品| 中国女人久久久| 欧美一区二区视频在线观看2020 | 久久精品色图| 久久一区二区三区av| 在线看日韩欧美| 欧美国产极速在线| 国产精品99久久久久久久女警 | 久久久精品2019中文字幕神马| 国产欧美日韩激情| 浪潮色综合久久天堂| 亚洲精品影院| 欧美伊人久久久久久久久影院| 国产一区二区三区av电影 | 日韩视频中文字幕| 国产精品高潮呻吟久久| 久久国产精品一区二区三区| 欧美肥婆在线| 亚洲综合导航| 亚洲国产va精品久久久不卡综合| 欧美激情视频免费观看| 亚洲在线观看视频| 欧美国产日韩一区二区在线观看| 一区二区久久久久| 激情av一区二区| 欧美性大战久久久久| 久久久国产成人精品| 一区二区欧美在线观看| 久久在线播放| 亚洲视频综合| 伊人春色精品| 国产精品日韩专区| 欧美二区在线观看| 欧美一区二区三区免费视| 亚洲人成网站在线观看播放| 欧美日韩国产二区| 亚洲人成网站精品片在线观看| 久久精品国产免费观看| 99视频在线观看一区三区| 国产亚洲欧美一区二区三区| 欧美国产综合视频| 久久精品一区四区| 亚洲综合第一页| 亚洲人成网站777色婷婷| 久久久久久伊人| 亚洲在线观看视频网站| 亚洲精品美女91| 狠狠久久婷婷| 国产精品自拍视频| 欧美日韩视频不卡| 欧美激情麻豆| 免费成人高清| 久久裸体艺术| 久久精品国产一区二区三| 亚洲欧美国产日韩天堂区| 日韩视频在线观看国产| 欧美激情导航| 欧美高清在线视频观看不卡| 久久久国产精品一区| 西瓜成人精品人成网站| 亚洲视频中文| 亚洲一区二区三区精品动漫| 9久re热视频在线精品| 亚洲人成在线观看一区二区| 亚洲第一成人在线| 国内一区二区三区| 国内久久婷婷综合| 国外成人性视频| 极品尤物久久久av免费看| 国产在线欧美日韩| 黄色成人片子| 在线免费观看欧美| 亚洲国产天堂久久综合| 久久久噜噜噜久久中文字幕色伊伊| 一本色道久久综合亚洲精品按摩| 亚洲日本成人| 日韩天堂在线视频| 在线亚洲一区| 中文在线一区| 午夜免费日韩视频| 欧美一区二区三区婷婷月色| 午夜精品久久久久久久99樱桃 | 日韩亚洲欧美在线观看| 亚洲高清不卡一区| 亚洲人成亚洲人成在线观看| 91久久久久久久久| 日韩亚洲精品电影| 亚洲一区日本| 久久精品国产清高在天天线| 久久久久久伊人| 欧美激情一区二区三级高清视频| 欧美精品一区二区三区很污很色的| 欧美日韩国产精品一卡| 国产精品久久久久av| 国产在线精品二区| 亚洲精品一区二区网址| 宅男噜噜噜66一区二区| 欧美一区二区三区在线播放|