编程总结1

题目1:打印沙漏

我的代码:

include<stdio.h>

int n;
char a;
int l;
int sum=1;
int rest;
int space;
int icon;
int s;
int i;

int main()
{
scanf("%d %c",&n,&a);
if(n<5){
rest=n-1;
printf("%c\n%d",a,rest);
return 0;
}
for(l=3;sum<=n;l+=2){
sum+=2l;
}
l-=4;
rest=n-sum+l
2+4;
for(icon=l;icon>=1;icon-=2){
space=(l-icon)/2;
for(s=space;s>0;s--){
printf(" ");
}
for(i=icon;i>0;i--){
printf("%c",a);
}
printf("\n");
}
for(icon=3;icon<=l;icon+=2){
space=(l-icon)/2;
for(s=space;s>0;s--){
printf(" ");
}
for(i=icon;i>0;i--){
printf("%c",a);
}
printf("\n");
}
printf("%d",rest);
return 0;
}

2.设计思路
第一步:题目难度略大于平时的习题。
第二步:从网络上的相似模板得到启发,最终解的此题。
3.本题调试过程碰到问题及解决办法
4.运行结果截图

转载于:https://www.cnblogs.com/The-light-of-the-apocalypse/p/10363267.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值