当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

Gray value and thermal imaging understanding

Http-Sumggling Cache Vulnerability Analysis

163_技巧_Power BI 一键批量建立自定义字段参数

LeetCode brush questions (8)

数据治理体系演进简介

Exploration and practice of transaction link under multi-service mode

Machine Learning - Ensemble Learning

软件设计七大原则之开闭原则(Open-Closed Principle, OCP)

Official release 2022 Nanjing Zhibo Expo is scheduled to be held in Xinzhuang National Exhibition in October
字节秋招二面把我干懵了,问我SYN报文什么情况下会被丢弃?
随机推荐
STM32H743IIT6学习笔记02——USART
623. Add a row to a binary tree: Simple binary tree traversal problems
常用的免费Api接口网址
hello world、hello 计科人
No developers, received a job to develop an IoT system, do you want to do it?
官方发布·2022南京智博会定于10月份在新庄国展召开
Go 语言 strings 库常用方法
WPF开发随笔收录-WriteableBitmap绘制高性能曲线图
不是吧?还有人不会定位线上MySQL慢查询问题?
【分享】代码编程习惯:在多参数的方法的情况下需要对方法整理-即最多参数的方法为主要实现
【HMS core】【FAQ】Health Kit, Ads kit, Push Kit Typical Questions Collection 5
前沿技术数字孪生如何应用在智慧城市上?
莅临GOPS大会龙智展位,获取Forrester最新报告:《Forrester Wave:2021年第四季度企业服务管理报告》
巴比特 | 元宇宙每日必读:中国1775万件数字藏品分析报告显示,85%的已发行数藏开通了转赠功能...
Flink Yarn Per Job - JobManger 申请 Slot
澳洲站:电吹风AS/NZS 60335.2.23: 2017 安全标准测试
并非富人专属,一文让你对NFT改观
花的含义
I'm going crazy.Again A few days can not be A problem
Integration testing of software testing