Software engineers shall commit themselves to making the analysis, specification, design, development, testing and maintenance of software a beneficial and respected profession. In accordance with their commitment to the health, safety and welfare of the public, software engineers shall adhere to the following Eight Principles:

1. PUBLIC - Software engineers shall act consistently with the public interest.

2. CLIENT AND EMPLOYER - Software engineers shall act in a manner that is in the best interests of their client and employer consistent with the public interest.

3. PRODUCT - Software engineers shall ensure that their products and related modifications meet the highest professional standards possible.

4. JUDGMENT - Software engineers shall maintain integrity and independence in their professional judgment.

5. MANAGEMENT - Software engineering managers and leaders shall subscribe to and promote an ethical approach to the management of software development and maintenance.

6. PROFESSION - Software engineers shall advance the integrity and reputation of the profession consistent with the public interest.

7. COLLEAGUES - Software engineers shall be fair to and supportive of their colleagues.

8. SELF - Software engineers shall participate in lifelong learning regarding the practice of their profession and shall promote an ethical approach to the practice of the profession.

软件工程师应致力于对软件的分析,规范,设计,开发,测试和维护,对行业有一个有利的和受人尊敬的行业。软件工程师按照其对健康、安全和福利的承诺,坚持以下八项原则:

1。公共软件工程师应符合公众利益。
2。客户和雇主-软件工程师应以符合公众利益的方式,以符合其客户和雇主的最佳利益的方式行事。
3。产品-软件工程师应确保他们的产品和相关的修改符合最高的专业标准成为可能。
4。判断-软件工程师应保持其专业判断的完整性和独立性。
5。管理-软件工程管理者和领导者应该订阅和促进一个道德的方法,以管理软件开发和维护。
6。专业-软件工程师应提前与公众利益相一致的行业的完整性和声誉。
7。同事-软件工程师应该是公平和支持他们的同事。
8。自学软件工程师应参与终身学习,并对其专业实践,并促进职业道德的做法

 

 

 

 

电梯调度

#include "stdafx.h" 
  #include"math.h" 
  #include"stdlib.h" 
  #include"string.h" 
  struct Head 
  { 
          int nPosition; 
          bool bVisited; 
  }; 
  void Visit(struct Head *pHead) 
  { 
      printf("visite cy:%d\n",pHead->nPosition); 
      pHead->bVisited=true; 
  } 
  int ReadInputKeyboard(struct Head *pHead,int *pCurrentPosition,int nMaxNumber) 
  { 
      int i; 
      printf("please input Current position:"); 
      scanf("%d",pCurrentPosition); 
      printf("please input will visit position:"); 
      for(i=0;i<nMaxNumber;i++) 
      { 
          scanf("%d",&pHead[i].nPosition); 
          pHead[i].bVisited=false; 
          if(pHead[i].nPosition<0) 
          break; 
      } 
      return i; 
  } 
  int ReadInputFile(struct Head *pHead,int *pCurrentPosition,int nMaxNumber) 
  { 
      int i; 
      char szFileName[256],*q,*p,szTemp[20]; 
      printf("please input filename:"); 
      scanf("%s",szFileName); 
    
      FILE *pFile=fopen(szFileName,"r"); 
      if(pFile==NULL) 
      { 
          printf("open file %s error",szFileName); 
          return -1; 
      } 
    
      for(i=0;!feof(pFile) &&i<nMaxNumber;) 
      { 
          p=szFileName; 
          fgets(p,256,pFile); 
          while(q=strchr(p,',')) 
          { 
              memset(szTemp,0,sizeof(szTemp)*sizeof(char)); 
              strncpy(szTemp,p,q-p); 
              p=q+1; 
              if(i==0) 
                  *pCurrentPosition=atoi(szTemp); 
              else 
              { 
                  pHead[i-1].nPosition=atoi(szTemp); 
                  pHead[i-1].bVisited=false; 
              } 
              i++; 
          } 
          memset(szTemp,0,sizeof(szTemp)*sizeof(char)); 
          pHead[i-1].nPosition=atoi(p); 
          pHead[i-1].bVisited=false; 
          //i++; 

      } 
      fclose(pFile); 
      return i; 
  } 
    
  int FifoVisit(int nCurrentPosition,struct Head *pHead,int nNumber) 
  { 
      //先来先服务 

      int nHaveVisited=0; 
      int nMoveDistance=0; 
      int i; 
      while(nHaveVisited<nNumber) 
      { 
          for(i=0;i<nNumber;i++) 
          { 
              if(pHead[i].bVisited) 
              continue; 
              Visit(&pHead[i]); 
              nHaveVisited++; 
              nMoveDistance+=abs(nCurrentPosition-pHead[i].nPosition); 
              nCurrentPosition=pHead[i].nPosition; 
          } 
      } 
      printf("the sum of move distance:%d\n",nMoveDistance); 
      return nMoveDistance; 
  } 
    
  int SsfoVisit(int nCurrentPosition,struct Head *pHead,int nNumber) 
  { 
  // 最短寻找时间优先 

      int nHaveVisited=0; 
      int nMoveDistance=0; 
      int nMinDistance=0; 
      int nMinIndex=0; 
      int i; 
      while(nHaveVisited<nNumber) 
      { 
          nMinDistance=0xffff; 
          nMinIndex=0; 
          //找最小值 

          for(i=0;i<nNumber;i++) 
          { 
              if(pHead[i].bVisited) 
              continue; 
              if(nMinDistance>abs(pHead[i].nPosition-nCurrentPosition)) 
              { 
                  nMinDistance=abs(pHead[i].nPosition-nCurrentPosition); 
                  nMinIndex=i; 
              } 
          } 
          //访问 

          Visit(&pHead[nMinIndex]); 
          nHaveVisited++; 
          nMoveDistance+=nMinDistance; 
          nCurrentPosition=pHead[nMinIndex].nPosition; 
      } 
      printf("the sum of move distance:%d\n",nMoveDistance); 
      return nMoveDistance; 
  } 
  int DtVisit(int nCurrentPosition,bool bOut,struct Head *pHead,int nNumber) 
  { 
  //电梯调度算法 

      int nHaveVisited=0; 
      int nMoveDistance=0; 
      int nMinDistance=0; 
      int nMinIndex=0; 
      int i; 
      while(nHaveVisited<nNumber) 
      { 
          nMinDistance=0xffff; 
          nMinIndex=0; 
          //找最小值 

          for(i=0;i<nNumber;i++) 
          { 
              if(pHead[i].bVisited) 
              continue; 
              if(bOut&&pHead[i].nPosition<nCurrentPosition||!bOut&&pHead[i].nPosition>nCurrentPosition) 
              { 
                  if(nMinDistance>abs(pHead[i].nPosition-nCurrentPosition)) 
                  { 
                      nMinDistance=abs(pHead[i].nPosition-nCurrentPosition); 
                      nMinIndex=i; 
                  } 
              } 
          } 
          if(nMinDistance==0xffff) 
          { 
              bOut=!bOut; 
              continue; 
          } 
    
          //访问 

          Visit(&pHead[nMinIndex]); 
          nHaveVisited++; 
          nMoveDistance+=nMinDistance; 
          nCurrentPosition=pHead[nMinIndex].nPosition; 
      } 
         printf("the sum of move distance:%d\n",nMoveDistance); 
         return nMoveDistance; 
  } 
  int DxVisit(int nCurrentPosition,struct Head *pHead,int nNumber) 
  { 
          //单向调度算法 

      int nHaveVisited=0; 
      int nMoveDistance=0; 
      int nMinDistance=0; 
      int nMinIndex=0; 
      int i; 
      while(nHaveVisited<nNumber) 
      { 
          nMinDistance=0xffff; 
          nMinIndex=0; 
          //找最小值 

          for(i=0;i<nNumber;i++) 
          { 
              if(pHead[i].bVisited) 
              continue; 
              if(pHead[i].nPosition>nCurrentPosition ) 
              { 
                  if(nMinDistance>abs(pHead[i].nPosition-nCurrentPosition)) 
                  { 
                      nMinDistance=abs(pHead[i].nPosition-nCurrentPosition); 
                      nMinIndex=i; 
                  } 
                  } 
         } 
         if(nMinDistance==0xffff) 
      { 
          nMoveDistance+=199-nCurrentPosition; 
          nCurrentPosition=0; 
          continue; 
      } 
    
      //访问 

          Visit(&pHead[nMinIndex]); 
      nHaveVisited++; 
      nMoveDistance+=nMinDistance; 
      nCurrentPosition=pHead[nMinIndex].nPosition; 
      } 
      printf("the sum of move distance:%d\n",nMoveDistance); 
      return nMoveDistance; 
  } 
  int main(int argc, char* argv[]) 
  { 
  //p114 

  struct Head mylist[20];//={98,false,183,false,37,false,122,false,14,false,124,false,65,false,67,false}; 

  //int nCurrentPosition=53; 

  //int nRealNumber=8; 

    
  int nCurrentPosition=0; 
  int nRealNumber=ReadInputFile(mylist,&nCurrentPosition,20); 
  // FifoVisit(nCurrentPosition,mylist,nRealNumber); 

  // SsfoVisit(nCurrentPosition,mylist,nRealNumber); 

  //DtVisit(nCurrentPosition,false,mylist,nRealNumber); 

  DxVisit(nCurrentPosition,mylist,nRealNumber); 
    
  return 0; 
  } 

 

posted @ 2016-09-03 12:00  2012040101235-张庭飞  阅读(103)  评论(0编辑  收藏  举报