国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

1016. Phone Bills (25) PAT甲級

2019-11-08 02:44:47
字體:
來源:轉載
供稿:網友

傳送門

#include<stdio.h>#include<algorithm>#include<string.h>using namespace std;#define MAX_N 1100struct Record{ char name[25]; int month,d,h,m; bool status;}r[MAX_N],temp;int toll[25];int n;bool cmp(Record a,Record b){ int m=strcmp(a.name,b.name); if(m!=0) return m<0; else if(a.month!=b.month) return a.month<b.month; else if(a.d!=b.d) return a.d<b.d; else if(a.h!=b.h) return a.h<b.h; else return a.m<b.m;}void get_time_money(int left,int right,int &time,int &money){ temp=r[left]; while(temp.d<r[right].d||temp.h<r[right].h||temp.m<r[right].m){ time++; money+=toll[temp.h]; temp.m++; if(temp.m>=60){ temp.m=0; temp.h++; } if(temp.h>=24){ temp.h=0; temp.d++; } }}int main(){ char sta[16]; for(int i=0;i<24;i++){ scanf("%d",&toll[i]); } scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%s %d:%d:%d:%d",r[i].name,&r[i].month,&r[i].d,&r[i].h,&r[i].m); scanf("%s",sta); if(strcmp(sta,"on-line")==0){ r[i].status=true; } else{ r[i].status=false; } } sort(r,r+n,cmp); int pair_first=0,pair_second,next; while(pair_first<n){ int isNeedPRint=0; next=pair_first; while(next<n&&strcmp(r[pair_first].name,r[next].name)==0){ if(isNeedPrint==0&&r[next].status==true){ isNeedPrint=1; } else if(isNeedPrint==1&&r[next].status==false){ isNeedPrint=2; } next++; } if(isNeedPrint<2){ pair_first=next; continue; } int SumOfMoney=0; printf("%s %02d/n",r[pair_first].name,r[pair_first].month); while(pair_first<next){ while(pair_first<next-1&&!(r[pair_first].status==true&&r[pair_first+1].status==false)){ pair_first++; } pair_second=pair_first+1; if(pair_second==next){ pair_first=next; break; } printf("%02d:%02d:%02d ",r[pair_first].d,r[pair_first].h,r[pair_first].m); printf("%02d:%02d:%02d ",r[pair_second].d,r[pair_second].h,r[pair_second].m); int time=0,money=0; get_time_money(pair_first,pair_second,time,money); SumOfMoney+=money; printf("%d $%.2f/n",time,money/100.0); pair_first=pair_second+1; } printf("Total amount: $%.2f/n",SumOfMoney/100.0); }}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 浦北县| 商都县| 五原县| 湛江市| 彝良县| 明星| 德州市| 铜川市| 呼玛县| 长沙市| 麻栗坡县| 云和县| 和顺县| 广州市| 沙湾县| 榆树市| 沽源县| 晋中市| 枝江市| 乌拉特前旗| 南城县| 靖西县| 略阳县| 巍山| 乐平市| 丰顺县| 五峰| 巴马| 大荔县| 邵阳市| 宣汉县| 临桂县| 邳州市| 琼海市| 固始县| 海伦市| 南丹县| 麟游县| 云南省| 黔南| 南木林县|