- #include<iostream>
- #include<cstdlib>
- #define k 7
- using namespace std;
- int main(){
- int b ,i ,j, k;
- char car[k]={'a','b','c','d','e','f','g'};
- int car_km[k]={'25','49','95','178','264','327','373'};
- for(i=0;i<k;i++){
- for(j=i+1;j<k;j++){
- if(car_km[j]-car_km[i]<=50){
- cout << car[i]<<" <-> "<< car[i]<<" "<<car_km[j]-car_km[j]<<"km 票價是"<<(car_km[j]-car_km[i])*2.5 << endl;
- }
- else if(51<car_km[j]-car_km[i]<=200){
- cout << car[i]<<" <-> "<< car[i]<<" "<<car[2][j]-car[2][i]<<"km 票價是"<<(car_km[j]-car_km[i])*2.2 << endl;
- }
- else if(car_km[j]-car_km[i]<200){
- cout << car[i]<<" <-> "<< car[i]<<" "<<car_km[j]-car_km[i]<<"km 票價是"<<(car_km[j]-car_km[i])*2 << endl;
- }
- }
- } system("Pause");
- return 0;
-
- }
複製代碼 |