标签:
问题陈述:
杭州电子科技大学 HANGZHOU DIANZI UNIVERSITY Online Judge Problem - 1008
问题分析:
简单题。
代码详解:
1 #include <iostream> 2 #include <cstdio> 3 4 using namespace std; 5 6 int main() 7 { 8 int i, n, m, time; 9 int floors[100] = {0}; 10 while(cin>>n && n) { 11 time = 0; 12 cin >> floors[0]; 13 time += floors[0]*6 + 5; 14 for(i=1; i<n; i++) { 15 cin >> floors[i]; 16 m = floors[i] - floors[i-1]; 17 if(m > 0) { 18 time += m*6 + 5; 19 }else{ 20 time += (-m)*4 + 5; 21 } 22 } 23 cout << time << endl; 24 } 25 return 0; 26 }
转载请注明出处:http://www.cnblogs.com/michaelwong/p/4287130.html
标签:
原文地址:http://www.cnblogs.com/michaelwong/p/4287130.html