C++编程:Call Forwarding
来源:互联网 发布:sqlserver培训中心 编辑:程序博客网 时间:2024/06/03 20:29
题目描述:
- All extensions consist of four digits.
- The extensions 0000 and 9999 are reserved for special use and will not be entered as information by an employee.
- Times are recorded in increments of 1 hour and are based on a clock that begins at 0000 at midnight every New Year's Eve. Therefore, when describing the time they are leaving, employees always use an integer between 0000 and 8784 (which is 366*24). The call forwarding system is completely reset at the beginning of the year.
- A call forward set to start at time X for a duration of Y will be in effect from time X to time X+Y inclusive.
输入样例:
21111 0100 0200 22221111 0301 0500 44442222 0200 0200 33333333 0250 1000 11117777 1000 2000 777700000050 11110150 11110200 11110225 22220270 11110320 11110320 33330900 30001250 33331250 7777900000003000 11119000
输出样例:
CALL FORWARDING OUTPUTSYSTEM 1AT 0050 CALL TO 1111 RINGS 1111AT 0150 CALL TO 1111 RINGS 2222AT 0200 CALL TO 1111 RINGS 3333AT 0225 CALL TO 2222 RINGS 3333AT 0270 CALL TO 1111 RINGS 9999AT 0320 CALL TO 1111 RINGS 4444AT 0320 CALL TO 3333 RINGS 4444AT 0900 CALL TO 3000 RINGS 3000AT 1250 CALL TO 3333 RINGS 1111AT 1250 CALL TO 7777 RINGS 9999SYSTEM 2AT 3000 CALL TO 1111 RINGS 1111END OF OUTPUT
输入描述:
输出描述:
程序限制:
程序可使用最大内存:
50240K程序运行最长耗时:
5000MS(毫秒)
解题思路:号码是规定的4个字符,电话可以随意转接,但是范围与(number[i][1]<=str<=number[i][1]+number[i][2])中间两个号码有关系。死扣这个关系,本题就变得简单了。
代码:
#include <iostream>#include <string>#include <cstring>#include <stdlib.h>using namespace std;string number[1000][4];string str2;int sum;string change(string str,int k){string str3;cin>>str2;str3=str2;bool ft=true;int i,p=0,num,num1,num2;while(p<k+2 && ft==true){ft=false;for(i=0;i<k;i++){num=atoi(str.c_str());num1=atoi(number[i][1].c_str());num2=atoi(number[i][2].c_str());if(str3==number[i][0] && num>=num1 && num<=(num1+num2)){p++;ft=true;str3=number[i][3];}}}if(p>=k+2) str3="9999";return str3;}int main(){int n,i,j;cin>>n;cout<<"CALL FORWARDING OUTPUT"<<endl;for(i=1;i<=n;i++){string str;j=0;while(cin>>str && str != "0000"){number[j][0]=str;cin>>number[j][1]>>number[j][2]>>number[j][3];j++;}sum=j;cout<<"SYSTEM "<<i<<endl;string str1;while(cin>>str1 && str1 != "9000"){cout<<"AT "<<str1<<" CALL TO ";string musics=change(str1,sum);cout<<str2<<" RINGS "<<musics<<endl;}}cout<<"END OF OUTPUT"<<endl;return 0;}
0 0
- C++编程:Call Forwarding
- call forwarding
- call forwarding调查
- Objective-C 运行时编程指南 之 Message Forwarding
- C Socket Forwarding
- Objective-C Message Forwarding
- 7.11 Call forwarding number andconditions +CCFC
- SIP Call Transfer and Call Forwarding Supplementary Services(cisco)
- Effective objective-C 理解消息forwarding
- Docker容器启动报WARNING: IPv4 forwarding is disabled.bridge-nf-call-iptables is disabled
- Effective Objective-C 2.0: Item 12: Understand Message Forwarding
- Exceptional C++: [Item 46 Forwarding Functions] [条款46 转发函数]
- python call c
- C system call test
- C and C++ call
- C call C++
- python call c dll
- 一、C Call Lua
- Android中shape的使用
- 常见的10个Objective-C基础面试题
- 如何去除dialog默认黑色边框
- 10000小时定律
- VC 编译警告:确保 $(OutDir)、$(TargetName) 和 $(TargetExt) 属性值与 %(Link.OutputFile) 中指定的值匹配。
- C++编程:Call Forwarding
- ServerSocket
- 在线Demo—城市基础设施管理
- Android_adb shell am/pm使用
- C/C++源码网站
- List集合删除元素
- 可以下载oracle database 12C for AIX HPUX Zlinux安装体验了
- IOS之分析网易新闻存储数据(CoreData的使用,增删改查)
- http://my-yii.blogspot.com/2013/09/yii-how-to-open-modal-via-ajax-via.html