[C++] hdoj1008简单题 →→→→→进入此内容的聊天室

来自 , 2020-06-13, 写在 C++, 查看 104 次.
URL http://www.code666.cn/view/68c694de
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.     int m;
  6.     int n;
  7.     int pre;
  8.     int total;    
  9.     for(cin>>m; m != 0; cin>>m){
  10.         cin>>n;
  11.         pre = n;
  12.         total = n * 6;
  13.         total = total + 5;
  14.         for(int i = 1; i < m; i++){            
  15.             cin>>n;
  16.             if(n > pre){
  17.                 total = total + 6 * (n - pre);
  18.                 pre = n;
  19.             }else if(n < pre){
  20.                 total = total + 4 * (pre - n);
  21.                 pre = n;
  22.             }
  23.             total = total + 5;
  24.         }
  25.         cout<<total<<endl;
  26.     }
  27. }

回复 "hdoj1008简单题"

这儿你可以回复上面这条便签

captcha