ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

CF32B Borze(模拟+字符串)(大佬勿喷)

2021-10-16 18:02:22  阅读:192  来源: 互联网

标签:输出 Borze 进制 number borze ternary 大佬 CF32B


题目描述

Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet.

输入格式

The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes).

输出格式

Output the decoded ternary number. It can have leading zeroes.

题意翻译

题面描述

三进制数字符号在Berland很受欢迎。如果用borze编码表示电报的三进制数。数字 0,1,20,1,2 分别被作为.-.--。你需要为borze编码解码。(把borze编码转换为三进制数)。

输入格式

第一行包含在Borze编码。字符串的长度介于 11 到 200200 个字符之间。这是保证给定的字符串是一个有效的一些三元数borze编码(这个数可能有前导零)。

输出格式

一个三进制数(如果有前导零要输出)。

输入输出样例

输入 #1

.-.--

输出 #1

012

输入 #2

--.

输出 #2

20

输入 #3

-..-.--

输出 #3

1012

CODE

#include <iostream>
using namespace std;

string str;

void zero(){
	cout << 0;
}

void one(){
	cout << 1;
}

void two(){
	cout << 2;
}

int main(){
	cin >> str;
	for(int i=0; i<str.size(); i++){
		if(str[i] == '.') zero();
		else if(str[i] == '-'){
			if(str[i+1] == '-') two();
			else one();
			str[i+1] = 'J';
		}
	}
	return 0;
}

AC记录

标签:输出,Borze,进制,number,borze,ternary,大佬,CF32B
来源: https://blog.csdn.net/m0_61067261/article/details/120801832

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有