武汉科技大学ACM :1005: 零起点学算法101——手机短号
Problem Description
大家都知道,手机号是一个11位长的数字串,同时,作为学生,还可以申请加入校园网,如果加入成功,你将另外拥有一个短号。假设所有的短号都是是 6+手机号的后5位,比如号码为13512345678的手机,对应的短号就是645678。
现在,如果给你一个11位长的手机号码,你能找出对应的短号吗?
Input
输入数据的第一行是一个N(N <= 200),表示有N个数据,接下来的N行每一行为一个11位的手机号码。
Output
输出应包括N行,每行包括一个对应的短号,输出应与输入的顺序一致。
Sample Input
2
13512345678
13787654321
Sample Output
645678
654321
HINT
如果用字符串,建议用scanf("%s")读入。
我的代码:
#include <iostream>
using namespace std;
int main()
{
int N;
cin>>N;
while(N--){
char a[];
cin>>a;
cout<<'';
for(int i=;i<;i++)
cout<<a[i];
cout<<endl;
}
return ;
}
其他代码:
#include<stdio.h>
#include<string.h>
int main()
{
int n,i=;
char phone[];
scanf("%d",&n);
for(i=;i<n;i++){
scanf("%s",phone);
phone[]='';
for(int j=;j<;j++)
putchar(phone[j]);
printf("\n");
}
return ;
}
#include <iostream> using namespace std; int main()
{
int N;
cin>>N;
if(N<= || N>)
return ;
char (*a)[]=new char[N][];
char (*r)[]=new char[N][];
for(int i=;i<N;++i)
{
cin>>a[i];
for(int j=;j<;++j)
{
r[i][] = '';
r[i][j-] = a[i][j];
r[i][] = '\0';
} }
for(int i=;i<N;++i)
{
cout<<r[i]<<endl;
}
return ;
}
武汉科技大学ACM :1005: 零起点学算法101——手机短号的更多相关文章
- Problem F: 零起点学算法101——统计字母数字等个数
#include<stdio.h> #include<string.h> int main(){ ]; while(gets(str)!=NULL){ ,b=,c=,d=; ; ...
- WUOJ-ACM :1003: 零起点学算法78——牛牛
武汉科技大学ACM :1003: 零起点学算法78--牛牛Problem Description牛牛是一种纸牌游戏,总共5张牌,规则如下: 如果找不到3张牌的点数之和是10的倍数,则为没牛: 如果其中 ...
- 1163: 零起点学算法70——Yes,I can!
1163: 零起点学算法70--Yes,I can! Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: ...
- 1164: 零起点学算法71——C语言合法标识符(存在问题)
1164: 零起点学算法71——C语言合法标识符 Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 10 ...
- 1147: 零起点学算法54——Fibonacc
1147: 零起点学算法54--Fibonacc Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 20 ...
- 1145: 零起点学算法52——数组中删数II
1145: 零起点学算法52--数组中删数II Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 293 ...
- 1137: 零起点学算法44——多组测试数据输出II
1137: 零起点学算法44--多组测试数据输出II Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: ...
- 1136: 零起点学算法43——多组测试数据输出I
1136: 零起点学算法43--多组测试数据输出I Time Limit: 1 Sec Memory Limit: 128 MB 64bit IO Format: %lldSubmitted: ...
- 1135: 零起点学算法42——多组测试数据(求和)IV
1135: 零起点学算法42--多组测试数据(求和)IV Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted ...
随机推荐
- Asp.net禁用页面缓存的方法
方法1.在Asp页面首部<head>中添加如下代码 Response.Buffer = True Response.ExpiresAbsolute = Now() - 1 Response ...
- HttpClient支持使用代理服务器以及身份认证
HttpClient Authentication Doument: http://hc.apache.org/httpclient-3.x/authentication.html HttpClien ...
- 安装centos mini版,无法联网,用yum安装软件提示 cannot find a valid baseurl for repo:base/7/x86_64 的解决方法
*无法联网的明显表现会有: cannot find a valid baseurl for repo:base/7/x86_64 1.yum install出现 Error: cannot find ...
- 宏定义 button 方法 --备
定义 #define BARBUTTON(TITLE, SELECTOR) [[[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButto ...
- Ruby on Rails Tutorial读书笔记-1
只是怕忘了命令,全部撸一次,记个大概.. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 安装Ruby之前,先要安装RVM: curl -L https://get.rvm.io | bas ...
- IBM总裁郭士纳总结的四类人
IBM总裁郭士纳总结的四类人, 您属于哪一种呢-欢迎就此话题发表评论 积极采取行动促使事件发生的人 被动接受所发生事件的人 对事件持旁观者心态的人 什么事都不关心的人
- 用vlc SDK创建一个播放视频文件和RTSP流视频的Demo
#include <stdio.h> #include <tchar.h> #include <time.h> #include <windows.h> ...
- java调优随记-堆和栈
基础知识: 关于堆和栈,堆和栈是程序运行的关键,关于堆和栈的定义和解释可自行搜索,我比较认可以程序运行过程中他们扮演的角色作为对比的点:堆是存储的单位,而栈是程序运行时的单位.栈解决的是程序的运行问题 ...
- Redis分布式缓存 教程以及DEMO
原文地址:http://blog.csdn.net/qiujialongjjj/article/category/1800171 redis demo源码下载:http://download.csdn ...
- Java毫秒转换成日期格式
import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.uti ...