c语言输出一行星星代码,C语言打印星星的问题
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include int main(void)
{
int index, up, lines;
printf("请输入将要显示的行数:\n");
while(scanf("%d", &up) == 1)
{
if(up % 2 == 0)
{
for(lines = 1; lines <= up / 2; lines++)
{
for(index = 0; index < lines; index++)
printf("*");
for(index = 0; index < up - 2 * lines; index++)
printf(" ");
for(index = 0; index < lines; index++)
printf("*");
printf("\n");
}
for(lines = up / 2 - 1; lines > 0; lines--)
{
for(index = lines; index > 0; index--)
printf("*");
for(index = 0; index < up - 2 * lines; index++)
printf(" ");
for(index = lines; index > 0; index--)
printf("*");
printf("\n");
}
}
else
{
for(lines = 0; lines <= up / 2; lines++)
{
for(index = 0; index < lines; index++)
printf("*");
for(index = 0; index < up - 2 * lines; index++)
printf(" ");
for(index = 0; index < lines; index++)
printf("*");
printf("\n");
}
for(lines = up / 2; lines > 0; lines--)
{
for(index = lines; index > 0; index--)
printf("*");
for(index = 0; index < up - 2 * lines; index++)
printf(" ");
for(index = lines; index > 0; index--)
printf("*");
printf("\n");
}
}
printf("请输入一个新的行数:\n");
}
system("PAUSE");
return 0;
}
这次就帮你写了(实际只是作为新手的自己想要练练手
),这种题目还是自己想想的比较好,这算是最基础的了
c语言输出一行星星代码,C语言打印星星的问题相关推荐
- python实践输出星星_python中怎么打印星星
for循环: 1.有大括号与无大括号的区别: 循环体只能有一条语句, 如果需要执行的语句超过一条,就要加大括号将它们变为一条复合语句.//for循环如此,while循环也是如此. for(int i= ...
- C语言 输出菱形 最短代码!
哈哈,本人大四了,整理代码偶尔发现大一时候上c语言实验课捣鼓出来的打印菱形代码,当然可能很多人都发过,但这个真的是我上课琢磨出来的,发出来分享一下. #include <stdio.h> ...
- C语言存储管理模拟程序设计代码,C语言程序设计教学大纲.doc
目 录 <C语言程序设计>教学大纲1 <实用操作系统>教学大纲5 <网页设计>教学大纲8 <计算机硬件基础>教学大纲12 <计算机网络技术> ...
- c语言交通违章编程代码,C语言程序设计交通处罚单管理系统 报告(内含代码).doc...
C语言程序设计交通处罚单管理系统 报告(内含代码) C语言程序设计 姓名:张强强 学号:座机电话号码695 班序号:011121 前言: C语言是近年来国内得到迅速推广使用的一种计算机语言.C语言程序 ...
- c语言输出数字1-100,c语言输出100以内素数 c语言编程输出1到100之间素数并求和,在线等,急?...
C语言,编写函数判断一个整数是否为素数,在主函数中调用该函数并输出100以内的全部素数? 参考代码: #include <stdio.h> int is_prime_numbe ...
- c语言万年历查询程序代码,C语言 万年历程序(示例代码)
C语言 万年历程序 原代码:[email protected]:~/c++$ cat 123.c #include #define Mon 1 #define Tues 2 #define We ...
- 摇摇棒C语言程序,摇摇棒代码C语言.doc
摇摇棒代码C语言 /**************************************************************************** * * ********* ...
- c语言万年历查询程序代码,C语言小程序实现万年历
分享一个简单的小程序,看看如何打印万年历吧~ 程序打开时时这样的,输入一个年份: 比如输入2016再回车,效果如下: 下面我们来看看实现这个程序的代码吧: #include #include #def ...
- c语言删除一行程序代码,删除C语言程序中所有的注释语句的实现代码
一种解法非常好:状态机.在各种状态之间跳转,逻辑清晰,不易出错,出错了也容易调试. 下面把代码贴出来: #include int state; int c1,c2; void change_state ...
最新文章
- 图解eclipse+myeclipse完全绿色版制作过程
- 对话中小企业信息化甲乙方(2)
- java soap封装_Java SOAPMessage.writeTo方法代码示例
- 基于ISM的大数据在建筑领域中的应用障碍分析
- canvas学习-----1px线条模糊问题
- 多线程是并行还是并发_并发,并行,线程,进程,异步和同步有相关性吗?
- mysql 电商实战_电商项目测试实战(一)
- jqGrid常用方法
- python基础教程第三版电子版-《python基础教程第三版》PDF高清完整版-免费下载...
- poj 2065 SETI(gauss---≡)
- 【ide】myeclipse项目右键没有configure
- 【groovy #1】groovy的相关知识
- 数值分析matlab最小二乘法,数值分析 最小二乘 matlab
- 蓝牙协议栈HFP SCO连接流程
- 【CVE-2021-4034】 漏洞详细原理以及复现,polkit的pkexec中的本地提权漏洞
- CopyMemory不同类型数据之间的复制
- html游戏转wxw,wf.html · wxw婉/flowChart - Gitee.com
- webpack多页面打包
- 微图中的高程DEM数据说明
- Solid Converter PDF中文版