UVa 490 - Rotating Sentences

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=431

题目:将输入的句子,反转90度后输出。

思路:第i行字符串旋转90度后,其字符为每一行的第i个字符。

 1 #include<iostream>
 2 #include<cstring>
 3 #include<cstdio>
 4 using namespace std;
 5
 6 int main()
 7 {
 8  // freopen("input.txt","r",stdin);
 9   char cc[101][109];
10   int aa[101];
11   string s;
12   int i,j=0,max=0,k=0;
13    memset(cc,‘ ‘,sizeof(cc));
14   while(getline(cin,s))
15   {
16      for(i=0;i<s.length();i++)
17          cc[i][k]=s[i];
18      if(s.length()>max)
19         max=s.length();
20      k++;
21   }
22     for(i=0;i<max;i++)
23       {
24        for(j=k-1;j>=0;j--)
25          cout<<cc[i][j];
26          cout<<endl;
27       }
28   return 0;
29 }
时间: 2024-10-12 12:18:44

UVa 490 - Rotating Sentences的相关文章

490 - Rotating Sentences

 Rotating Sentences  In ``Rotating Sentences,'' you are asked to rotate a series of input sentences 90 degrees clockwise. So instead of displaying the input sentences from left to right and top to bottom, your program will display them from top to bo

UVA490 Rotating Sentences

问题链接:UVA490 Rotating Sentences. 题意简述:输入若干行字符串,将其旋转90度后输出. 问题分析:需要一个二维数组存储输入的字符串,好在规模不大. 程序说明:封装了函数mygets()(函数gets()在新标准中,被建议不要使用,作用就自己做一个),其他都是套路. AC的C语言程序如下: /* UVA490 Rotating Sentences */ #include <stdio.h> #include <memory.h> #define MAXN

UVA_490:Rotating Sentences

"R  Ie   n  te  h  iD  ne  kc  ,a   r  tt  he  es  r  eo  fn  oc  re  e   s  Ia   i  ad  m,  .  " Language:C++ 4.8.2 #include<stdio.h> #include<string.h> #define MAXN 100+10 char str[MAXN][MAXN]; int main(void) { memset(str, 0, sizeo

UVA题目分类

题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes

UVa--Rotating Sentences

Rotating Sentences  In ``Rotating Sentences,'' you are asked to rotate a series of input sentences 90 degrees clockwise. So instead of displaying the input sentences from left to right and top to bottom, your program will display them from top to bot

寒假练习 01

这一系列的练习主要在Virtual Judge上进行,题目为小白书上的题目推荐. UVa 10055 注意两个数的大小关系,水题. #include <iostream> using namespace std; int main() { long long x, y; while(cin >> x >> y) { if(x > y) { swap(x, y); } cout << y - x << endl; } return 0; }

Hashmat the Brave Warrior

Hashmat the Brave Warrior XX自己有士兵a人, 敌军有士兵b人,自己的士兵永远比敌军少, 求对方比自己多多少人.       (虽说要从头刷,但是这样的还是太水了吧 2333333 喜闻乐见的错了因为2^32爆了int...These two numbers in each line denotes the number of soldiers in Hashmat's army and his opponent's army or vice versa 1 #incl

Rotating Scoreboard(半平面交模板题)

Rotating Scoreboard http://poj.org/problem?id=3335 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8506   Accepted: 3357 Description This year, ACM/ICPC World finals will be held in a hall in form of a simple polygon. The coaches and spe

Cube painting UVA 253

说说:一看到给立方体染色,开始还有点小害怕.毕竟高中数学里染色问题从来都不会简单.这道题的意思就是给立方体的六个面染色,然后判断两个染了色的立方体是否一样.其实仔细一想,立方体无非三对面,若开始确定两对面.如下面图Figure 1所示:假设1,2,6,5这四个面先确定(这只有唯一一种情况)之后,再放3,4,的时候无非两种情况.但这两种情况是不一样的,这也许就是题目所说的reflection.开始的想法是找出三对面,然后比较是否相等即可,不过实在想不出怎样来排除reflection的情况.所以只能