博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
L1-054 福到了 (15 分)
阅读量:4047 次
发布时间:2019-05-25

本文共 1137 字,大约阅读时间需要 3 分钟。

“福”字倒着贴,寓意“福到”。不论到底算不算民俗,本题且请你编写程序,把各种汉字倒过来输出。这里要处理的每个汉字是由一个 N × N 的网格组成的,网格中的元素或者为字符 @ 或者为空格。而倒过来的汉字所用的字符由裁判指定。

输入格式:

输入在第一行中给出倒过来的汉字所用的字符、以及网格的规模 N (不超过100的正整数),其间以 1 个空格分隔;随后 N 行,每行给出 N 个字符,或者为 @ 或者为空格。

输出格式:

输出倒置的网格,如样例所示。但是,如果这个字正过来倒过去是一样的,就先输出bu yong dao le,然后再用输入指定的字符将其输出。

输入样例 1:

$ 9 @  @@@@@@@@  @@@  @   @ @ @@@  @@@ @@@ @@@@@@@@ @ @ @@@@ @@@@@ @  @ @ @ @  @@@@@

输出样例 1:

$$$$$  $ $ $ $  $ $$$$$ $$$$ $ $ $$$$$$$$ $$$ $$$  $$$ $ $   $  $$$  $$$$$$$$  $

输入样例 2:

& 3@@@ @ @@@

输出样例 2:

bu yong dao le&&& & &&&

 1.一个数组搞定

#include
int main(){ char c; int n; char map[100][100]; scanf(" %c %d",&c,&n); getchar(); for(int i=0;i
=0;i--) { y=0; for(int j=n-1;j>=0;j--) { if(map[x][y]!=map[i][j]) { flag=1; break; } y++; } x++; } if(flag==0)printf("bu yong dao le\n"); for(int i=n-1;i>=0;i--) { for(int j=n-1;j>=0;j--) { if(map[i][j]=='@') printf("%c",c); else printf("%c",map[i][j]); } printf("\n"); } return 0; }

 

2.使用两个数组

#include
#include
int main(){ char c; char map[102][102]; char map2[102][102]; int n; scanf(" %c %d",&c,&n); getchar(); for(int i=0;i

 

转载地址:http://mtzci.baihongyu.com/

你可能感兴趣的文章
QT打开项目提示no valid settings file could be found
查看>>
Win10+VS+ESP32环境搭建
查看>>
Ubuntu+win10远程桌面
查看>>
flutter-实现圆角带边框的view(android无效)
查看>>
android 代码实现圆角
查看>>
flutter-解析json
查看>>
android中shader的使用
查看>>
java LinkedList与ArrayList迭代器遍历和for遍历对比
查看>>
drat中构造方法
查看>>
JavaScript的一些基础-数据类型
查看>>
JavaScript基础知识(2)
查看>>
转载一个webview开车指南以及实际项目中的使用
查看>>
android中对于非属性动画的整理
查看>>
一个简单的TabLayout的使用
查看>>
ReactNative使用Redux例子
查看>>
Promise的基本使用
查看>>
coursesa课程 Python 3 programming 统计文件有多少单词
查看>>
coursesa课程 Python 3 programming 输出每一行句子的第三个单词
查看>>
Returning a value from a function
查看>>
coursesa课程 Python 3 programming Functions can call other functions 函数调用另一个函数
查看>>