標題:
客運票價表
[打印本頁]
作者:
stephen
時間:
2010-5-15 09:38
標題:
客運票價表
作者:
b1081081
時間:
2010-5-15 10:44
哈哈 又是我第一個寫出來!!
#include <iostream>
#include <cstdlib>
#define n 7
using namespace std;
int main(void){
char city[n] = {'a','b','c','d','e','f','g'};
int city_km[n] = {25,49,95,178,264,327,373};
int i , j;
for(i = 0; i < n; i++){
for(j = i+1; j < n; j++){
if((city_km[j]-city_km[i])<=50){
cout << city[i] << " <=> " << city[j] << " 票價為" << (city_km[j]-city_km[i]) * 2.5 << endl;
}else if((city_km[j]-city_km[i])>50||(city_km[j]-city_km[i])<=200){
cout << city[i] << " <=> " << city[j] << " 票價為" << (city_km[j]-city_km[i]) * 2.2 << endl;
}else if((city_km[j]-city_km[i])>200){
cout << city[i] << " <=> " << city[j] << " 票價為" << (city_km[j]-city_km[i]) * 2 << endl;
}
}
}
system("pause");
return 0;
}
複製代碼
作者:
p17johnny
時間:
2010-5-15 11:26
我是第二名嗎??
#include <iostream>
#include <cstdlib>
#define city1 7
using namespace std;
int main(void){
char city[city1]={'A','B','C','D','E','F','G'};
int city_le[city1]={25 , 49 , 95 , 178 , 264 , 327 , 373 };
int i,j;
for (int i=0; i<city1; i++){
for(int j=i+1; j<city1; j++){
if ((city_le[j]-city_le[i])<=50){
cout<<endl;
cout<<city[i]<< "~"<< city[j]<<"價錢:"<<(city_le[j]-city_le[i])*2.5<<endl;
cout<<endl;
}else if((city_le[j]-city_le[i])>50||(city_le[j]-city_le[i])<=200){
cout<<endl;
cout<<city[i]<< "~"<< city[j]<<"價錢:"<<(city_le[j]-city_le[i])*2.2<<endl;
cout<<endl;
}else if((city_le[j]-city_le[i])>200){
cout<<endl;
cout<<city[i]<< "~"<< city[j]<<"價錢:"<<(city_le[j]-city_le[i])*2<<endl;
cout<<endl;
}
}
}
cout<<"怎麼這麼麻煩阿``好難``"<<endl;
cout<<endl;
system("pause");
return 0;
}
複製代碼
作者:
yachen392
時間:
2010-5-15 11:30
#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;
}
複製代碼
作者:
yachen392
時間:
2010-5-15 11:31
#include<iostream>
#include<cstdlib>
#define k 7
using namespace std;
int main(){
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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2