CDZSC_2016寒假个人赛(2)-C
2016-02-19 18:08
204 查看
Write a program that recognizes characters. Don’t worry, because you only need to recognize three digits: 1, 2 and 3. Here they are:
.*. *** ***
.*. ..* ..*
.*. *** ***
.*. *.. ..* .*.
*** ***
Input
The input contains only one test case, consisting of 6 lines. The first line contains n, the number of characters to recognize (1 ≤ n ≤ 10). Each of the next 5 lines contains 4n characters. Each character contains exactly 5 rows and 3 columns of characters followed
by an empty column (filled with ‘.’).
Output
The output should contain exactly one line, the recognized digits in one line.
Sample Input
3
.*..***.***.
.*....*...*.
.*..***.***.
.*..*.....*.
.*..***.***.
Sample Output
123
思路:
这题只有三个数字,1,2,3.所以只要判断5*n的二维字母表就可以了。
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
#define T 1000100
typedef long long ll;
int main()
{
#ifdef zsc
freopen("input.txt","r",stdin);
#endif
int n,i,j,k;
ll m;
char s[50][500];
while(~scanf("%d",&n))
{
m = 0;
for(i=0;i<5;++i){
scanf("\n%s",&s[i]);
}
for(i=1;s[0][i];++i){
if(s[0][i-1]=='.'&&s[0][i]=='*'){
if(s[0][i]=='*'&&s[1][i]=='*'&&s[2][i]=='*'
&&s[3][i]=='*'&&s[4][i]=='*'){
m = m*10 + 1;
}
else if(s[0][i]=='*'&&s[1][i]=='.'&&s[2][i]=='*'
&&s[3][i]=='*'&&s[4][i]=='*'){
m = m*10 + 2;
}
else if(s[0][i]=='*'&&s[1][i]=='.'&&s[2][i]=='*'
&&s[3][i]=='.'&&s[4][i]=='*'){
m = m*10 + 3;
}
}
}
printf("%lld\n",m);
}
return 0;
}
.*. *** ***
.*. ..* ..*
.*. *** ***
.*. *.. ..* .*.
*** ***
Input
The input contains only one test case, consisting of 6 lines. The first line contains n, the number of characters to recognize (1 ≤ n ≤ 10). Each of the next 5 lines contains 4n characters. Each character contains exactly 5 rows and 3 columns of characters followed
by an empty column (filled with ‘.’).
Output
The output should contain exactly one line, the recognized digits in one line.
Sample Input
3
.*..***.***.
.*....*...*.
.*..***.***.
.*..*.....*.
.*..***.***.
Sample Output
123
思路:
这题只有三个数字,1,2,3.所以只要判断5*n的二维字母表就可以了。
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
#define T 1000100
typedef long long ll;
int main()
{
#ifdef zsc
freopen("input.txt","r",stdin);
#endif
int n,i,j,k;
ll m;
char s[50][500];
while(~scanf("%d",&n))
{
m = 0;
for(i=0;i<5;++i){
scanf("\n%s",&s[i]);
}
for(i=1;s[0][i];++i){
if(s[0][i-1]=='.'&&s[0][i]=='*'){
if(s[0][i]=='*'&&s[1][i]=='*'&&s[2][i]=='*'
&&s[3][i]=='*'&&s[4][i]=='*'){
m = m*10 + 1;
}
else if(s[0][i]=='*'&&s[1][i]=='.'&&s[2][i]=='*'
&&s[3][i]=='*'&&s[4][i]=='*'){
m = m*10 + 2;
}
else if(s[0][i]=='*'&&s[1][i]=='.'&&s[2][i]=='*'
&&s[3][i]=='.'&&s[4][i]=='*'){
m = m*10 + 3;
}
}
}
printf("%lld\n",m);
}
return 0;
}
相关文章推荐
- Transformation 能将 Windows XP/Server 2003 操作系统,完美地模拟成 Windows Vista 的软件
- 用javascript和css模拟select的脚本
- PHP模拟asp.net的StringBuilder类实现方法
- C#使用ImitateLogin模拟登录百度
- javascript用层模拟可移动的小窗口
- 自编jQuery插件实现模拟alert和confirm
- JS模拟按钮点击功能的方法
- PHP模拟asp中response类实现方法
- 模拟Spring的简单实现
- javascript 模拟点击广告
- JQuery中模拟image的ajaxPrefilter与ajaxTransport处理
- php实现模拟post请求用法实例
- JavaScript实现MIPS乘法模拟的方法
- 模拟xcopy的函数
- JS模拟实现Select效果代码
- php模拟服务器实现autoindex效果的方法
- C# SendInput 模拟鼠标操作的实现方法
- PHP模拟登陆163邮箱发邮件及获取通讯录列表的方法
- js实现模拟银行卡账号输入显示效果
- JS模拟并美化的表单控件完整实例