1036. 跟奥巴马一起编程(15)
来源:互联网 发布:网络舞蹈培训学校 编辑:程序博客网 时间:2024/05/16 10:18
1036. 跟奥巴马一起编程(15)
题目
美国总统奥巴马不仅呼吁所有人都学习编程,甚至以身作则编写代码,成为美国历史上首位编写计算机代码的总统。2014年底,为庆祝“计算机科学教育周”正式启动,奥巴马编写了很简单的计算机代码:在屏幕上画一个正方形。现在你也跟他一起画吧!
输入格式:
输入在一行中给出正方形边长N(3<=N<=20)和组成正方形边的某种字符C,间隔一个空格。
输出格式:
输出由给定字符C画出的正方形。但是注意到行间距比列间距大,所以为了让结果看上去更像正方形,我们输出的行数实际上是列数的50%(四舍五入取整)。
输入样例:
10 a
输出样例:
aaaaaaaaaaa aa aa aaaaaaaaaaa
代码
#include <stdio.h>#include <stdlib.h>int main(void){ int i,j,n; char c; scanf("%d %c",&n,&c); for(i=0;i<n;i++) printf("%c",c); printf("\n"); for(i=0;i<(n-3)/2;i++) { for(j=0;j<n;j++) if(j==0||j==n-1) printf("%c",c); else printf(" "); printf("\n"); } for(i=0;i<n;i++) printf("%c",c); return 0;}
阅读全文
0 0
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 1036. 跟奥巴马一起编程(15)
- 美团云OVS-DPDK 2017年工作总结(SRIOV、热升级、热扩容、跨OVS-kernel热迁移)
- Reinforcement learning tips
- pdf_分页器脚本程序
- Construct 2做游戏
- AttributeError: 'dict' object has no attribute 'interitems'
- 1036. 跟奥巴马一起编程(15)
- Linux学习之C语言编程训练2
- OpenCV-Python-Tutorial[3]
- python中read() readline()以及readlines()用法
- test
- 数据库的增删改查
- zoj--3983(CCPC秦皇岛)
- 51Nod-1264-线段相交
- html中使用div块级元素布局的两种方法