DES:给出一个字符串。连续空格的个数代表一个新的字符。奇数个表示0。偶数个表示1。然后根据这个码作为ASCII码。写出对应的字符。就是统计空格个数。二进制转换成十进制的小模拟。但是比赛的时候敲得很不顺。

 #include<stdio.h>
#include<string.h>
#include<map>
#include<vector>
#include<math.h>
#include<iostream>
#include<map>
using namespace std; char str[];
int num[];
char anss[];
int cou;
int tt; void change()
{
int temp = (cou % );
int ans = ;
tt = ;
char la;
for (int i=; i<temp; ++i)
{
num[cou++] = ;
}
for (int i=; i<cou; i+=)
{
int t = ;
ans = ;
for (int j=i; j<i+; ++j)
{
ans += pow(, t) * num[j];
t--;
}
if (ans >= && ans <= )
{
int hh = ans + int('A');
hh -= ;
la = char(hh);
}
else if (ans == ) la = '.';
else if (ans == ) la = '-';
else if (ans == ) la = ',';
else if (ans == ) la = '\'';
else if (ans == ) la = ' ';
else if (ans == ) la = '?';
anss[tt++] = la;
}
} int main()
{
cou = ;
while(gets(str))
{
int len = strlen(str);
int cnt = ;
if (str[] == '*')
{
change();
int st = ;
while(anss[st] == ' ')
st++;
int ed = tt-;
while(anss[ed] == ' ')
ed--;
for (int i=st; i<=ed; ++i)
{
cout << anss[i];
}
cout << endl;
memset(num, , sizeof(num));
memset(anss, , sizeof(anss));
cou = ;
continue;
}
if (str[] == '#')
break; for (int i=; i<len; ++i)
{
cnt = ;
if (str[i] == ' ')
{
int j;
for (j=i; ; j++)
{
if (str[j] != ' ')
break;
cnt++;
}
if (cnt % == ) num[cou++] = ;
else num[cou++] = ;
cnt = ;
i = j;
}
}
}
return ;
}

LOoK

UVALive 4174的更多相关文章

  1. UVALive - 4108 SKYLINE[线段树]

    UVALive - 4108 SKYLINE Time Limit: 3000MS     64bit IO Format: %lld & %llu Submit Status uDebug ...

  2. UVALive - 3942 Remember the Word[树状数组]

    UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...

  3. UVALive - 3942 Remember the Word[Trie DP]

    UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...

  4. 思维 UVALive 3708 Graveyard

    题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...

  5. UVALive 6145 Version Controlled IDE(可持久化treap、rope)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  6. UVALive 6508 Permutation Graphs

    Permutation Graphs Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit ...

  7. UVALive 6500 Boxes

    Boxes Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Pract ...

  8. UVALive 6948 Jokewithpermutation dfs

    题目链接:UVALive 6948  Jokewithpermutation 题意:给一串数字序列,没有空格,拆成从1到N的连续数列. dfs. 可以计算出N的值,也可以直接检验当前数组是否合法. # ...

  9. 【暑假】[实用数据结构]UVAlive 3135 Argus

    UVAlive 3135 Argus Argus Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %l ...

随机推荐

  1. bzoj 2118 墨墨的等式 - 图论最短路建模

    墨墨突然对等式很感兴趣,他正在研究a1x1+a2y2+…+anxn=B存在非负整数解的条件,他要求你编写一个程序,给定N.{an}.以及B的取值范围,求出有多少B可以使等式存在非负整数解. Input ...

  2. poj 1274 The Prefect Stall - 二分匹配

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 22736   Accepted: 10144 Description Far ...

  3. Python3基础 list 访问列表中的列表的元素

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  4. UVA796 Critical Links(求桥) 题解

    题意:求桥 思路:求桥的条件是:(u,v)是父子边时 low[v]>dfn[u] 所以我们要解决的问题是怎么判断u,v是父子边(也叫树枝边).我们在进行dfs的时候,要加入一个fa表示当前进行搜 ...

  5. 简单Shell案例

    使用shell命令进行左对齐或者右对齐 [root@bj-aws-yace-tbj mnt]# cat test.sh #! /bin/bash file=./test.txt echo -e &qu ...

  6. 【镜像地址】Maven地址列表

    1.国内OSChina提供的镜像,非常不错 <mirror> <id>CN</id> <name>OSChina Central</name> ...

  7. HDU 6127 Hard challenge(扫描线)

    http://acm.hdu.edu.cn/showproblem.php?pid=6127 题意: 有n个点,每个点有一个$(x,y)$坐标和一个权值,任意两点之间都有连线,并且连线的权值为两个顶点 ...

  8. tornado 如何向html传list变量啊?

    py: html:

  9. zeptojs库解读2之事件模块

    第一,通过obj.addEventListener("click",fn)绑定的事件,你不能通过obj.onclick = null;来移除绑定点击事件的所有回调函数. 所以引入第 ...

  10. go 接口

    1. package main import ( "fmt" ) type Phone interface { call() } type NokiaPhone struct { ...