当前位置:网站首页>C语言例题-打印日历
C语言例题-打印日历
2022-08-05 11:49:00 【Blue_lan18】
编写程序显示单月的日历。用户指定这个月的天数和该月起始日是星期几。
# include <stdio.h>
int main()
{
int day;
int i, j;
int week;
printf("Enter number of days in month: ");
scanf("%d", &day);
printf("Enter starting day of the week (1 = Sun, 7 = Sat): ");
scanf("%d", &week);
for(j = 1; j < week; j++){
printf(" ");
}
//打出日历开始前的空格,一个空格是4个字节
for(i = 1; i <= day; i++){
printf("%4d", i);
if( (i + week -1) % 7 == 0){
printf("\n");
}
//每7天换一行
}
printf("\n");
return 0;
}
边栏推荐
- JS 从零手写实现一个call、apply方法
- Security Issues and Prevention in Web3
- 623. 在二叉树中增加一行 : 简单二叉树遍历运用题
- 碘乙酰胺在Desthiobiotin-Iodoacetamide试剂中的作用?
- 不是吧?还有人不会定位线上MySQL慢查询问题?
- 平安萌娃卡保险怎么样?让父母读懂几个识别产品的方法
- Version Control | Longzhi invites you to go to the GOPS Global Operation and Maintenance Conference to explore the road of large-scale, agile, high-quality and open software development and operation
- 手把手教你定位线上MySQL慢查询问题,包教包会
- Machine Learning - Ensemble Learning
- 巴比特 | 元宇宙每日必读:中国1775万件数字藏品分析报告显示,85%的已发行数藏开通了转赠功能...
猜你喜欢
D-Desthiobiotin-PEG4-Maleimide主要物理性质特点 !
Five reasons why developers choose Klocwork, a static analysis tool for code quality, for software security
冬日里,28℃的爱情
Mathcad 15.0软件安装包下载及安装教程
Go 语言快速入门指南: 基本类型
Go编译原理系列9(函数内联)
字节秋招二面把我干懵了,问我SYN报文什么情况下会被丢弃?
STM32H743IIT6学习笔记01——CubeMX新建工程文件
Gao Zelong attended the Boao Global Tourism Ecology Conference to talk about Metaverse and Future Network Technology
小红的aba子序列(离散化、二分、dp维护区间最短)
随机推荐
Go Quick Start Guide: Basic Types
D-Desthiobiotin-PEG4-Maleimide主要物理性质特点 !
Apache APISIX Ingress v1.5-rc1 发布
查询优化(TTFB过长)left join索引未生效
关注微信公众号,自动登陆网站
Integration testing of software testing
“蘑菇书”是怎样磨出来的?
【HMS core】【FAQ】Health Kit, Ads kit, Push Kit Typical Questions Collection 5
nyoj757 期末考试 (优先队列)
2022 极术通讯-基于安谋科技 “星辰” STAR-MC1的灵动MM32F2570开发板深度评测
Cesium.js点线面绘制
789. 数的范围
【硬件架构的艺术】学习笔记(3)处理多个时钟
使用Netty编写通用redis客户端(可指定服务器地址与端口号连接任意redis)
2022年6月互联网医疗领域月度观察
Go编译原理系列9(函数内联)
Official release 2022 Nanjing Zhibo Expo is scheduled to be held in Xinzhuang National Exhibition in October
790. 数的三次方根
常用的免费Api接口网址
LeetCode刷题(8)