UVa 483 - Word Scramble
题目大意:给一个由单词组成的句子,只反转单词内部的次序而不改变单词之间的次序。如“I love you.”转换成“I evol .uoy”。
1 #include <cstdio> 2 #include <cstring> 3 4 int main() 5 { 6 #ifdef LOCAL 7 freopen("in", "r", stdin); 8 #endif 9 int s, e; 10 char str[100000]; 11 while (gets(str)) 12 { 13 bool in_word = false; 14 int len = strlen(str); 15 int p = 0; 16 while (p < len) 17 { 18 while (p < len && str[p] == ' ') 19 { 20 putchar(' '); 21 p++; 22 } 23 s = p; 24 while (p < len && str[p] != ' ') p++; 25 e = p - 1; 26 for (int i = e; i >= s; i--) 27 putchar(str[i]); 28 } 29 printf("\n"); 30 } 31 return 0; 32 }
View Code
转载于:https://www.cnblogs.com/xiaobaibuhei/p/3299703.html
UVa 483 - Word Scramble相关推荐
- UVa483 Word Scramble
读取一行字符串,把空格间的字符串反转 具体代码参考: https://github.com/wuli2496/OJ/blob/master/UVa/483Word%20Scramble.cpp
- UVa 642 - Word Amalgamation
题目:给你一个单词列表.再给你一些新的单词.输出列表中又一次排列能得到此新单词的词. 分析:字符串.对每一个字符串的字母排序生成新的传f(str).总体排序,用二分来查找就可以. 说明:注意输出要满足 ...
- UVa 10508 - Word Morphing
題目:有一些長度相同的字符串,從起始字符串每次改變一個字符,轉化成其他字符,求轉化順序. 分析:簡單題.直接求出不同字符的個數排序輸出即可. 說明:題目的條件都是迷惑的\(^o^)/~. #inclu ...
- π-Algorithmist分类题目(1)
原题网站:Algorithmist,http://www.algorithmist.com/index.php/Main_Page π-Algorithmist分类题目(1) Sorting UVAL ...
- TYUT-A专题题解(一)
TYUT-A专题题解(一) 01A Ad Hoc UVA353 LA5247 Pesky Palindromes[回文] - 海岛Blog - CSDN博客 UVA947 Master Mind He ...
- Competitive Programming 3题解
题目一览: Competitive Programming 3: The New Lower Bound of Programming Contests(1) Competitive Programm ...
- Competitive Programming专题题解(1)
Competitive Programming题解 AOAPC I: Beginning Algorithm Contests 题解 CP2-1.1.1 Easy(Ad Hoc Problems) P ...
- Emscripten 单词_单词拼写(23) | 打电脑拼单词 Type Spelling Words on a Computer
点击上方蓝字,关注我们哦Fun Ways to Practice Spelling Words Spelling words are a fact of life with elementary sc ...
- uva 1401 - Remember the Word
一个简单的字典树上的dp: 代码: 1 #include<cstdio> 2 #include<cstring> 3 #include<queue> 4 #defi ...
- Word UVA - 517 状态压缩 暴力搜索
问题 https://vjudge.net/problem/UVA-517 分析 每次都循环到字典序最小的时候记录. 一共最多有2162^16216种,因为每种状态都变到字典序最小的时候,所以实际的远 ...
最新文章
- VirtualBox虚拟机中启用usb3.0却无法显示u盘的解决方法
- Java中的static———静态变量
- F盘无法访问设备硬件出现致命错误,导致请求失败数据找回的方案
- C# 2.0 套接字编程实例初探
- PHP 在作为中间件时print无返回值问题
- 9张图带你领略AI态势!
- 2021浙江高考成绩排名查询,2021年浙江高考成绩排名查询,第一批分数线23日公布...
- Remote Desktop 访问设置
- python教程2019全套-如何领取Python2019 全套视频教程
- 用PLC和触摸屏设计用户可编程的控制项目
- python矩阵连乘_第3章 动态规划——矩阵连乘最优计算方式查找
- 小程序中从后台获取内容纯数字、纯字母超出父盒子宽度时不换行 解决方法
- 基于STM32的DDS信号发生器
- archive = ZipFile(filename, ‘w‘, ZIP_DEFLATED, allowZip64=True)—— 已解决
- 并行编程--MPI开发入门
- 提示fxp不是一个目标文件
- 禅与摩托车维修艺术 摘选
- 二叉树的父子节点位置关系
- CouchDB查询文档
- 阿里Java学习路线:阶段 1:Java语言基础-Java面向对象编程:第30章:链表的定义与使用:课时145:综合实战:超市购物车(含完整代码)