当前位置:网站首页>Classic examples of C language switch case statement conversion date format
Classic examples of C language switch case statement conversion date format
2022-07-24 00:26:00 【Blue_ lan18】
Write the program below , Display the date in this format . User by month / Japan / Enter the date in the format of year , Then the computer shows “ legal ” Format date :
Enter date (mm/dd/yy): 7/19/14
Dated this 19th day of July,2014.
# include <stdio.h>
int main()
{
int month, day, year;
printf("Enter date (mm/dd/yy): ");
scanf("%d/%d/%d", &month, &day, &year);
printf("Dated this %d", day);
switch(day){
case 1: case 21: case 31:
printf("st");
break;
case 2: case 22:
printf("nd");
break;
case 3: case 13: case 23:
printf("rd");
break;
default: printf("th");
break;
}
printf(" day of ");
switch(month){
case 1: printf("January"); break;
case 2: printf("February"); break;
case 3: printf("March"); break;
case 4: printf("April"); break;
case 5: printf("May"); break;
case 6: printf("June"); break;
case 7: printf("July"); break;
case 8: printf("August"); break;
case 9: printf("September"); break;
case 10: printf("October"); break;
case 11: printf("November"); break;
case 12: printf("Decembery"); break;
}
printf(", 20%.2d.\n", year);
return 0;
}

Be careful ,%.2d Used to display the last two digits of the year . If you use %d Instead , Then the year with the penultimate zero will be displayed incorrectly ( It will put 2001 Display as 201).
边栏推荐
- php实现 Stripe订阅
- 《天幕红尘》笔记与思考(六)因缺而需
- Inftnews | protect the "Snow Mountain Spirit", and the 42verse "digital ecological protection" public welfare project is about to start
- English语法_指示代词 - So
- [video game training] non contact object size and shape measurement 2020 video game G
- AWS Article 3 how to publish message to IOT mqtt in go language
- Summarize the plan, clarify the direction, concentrate and start a new situation -- the Counterpart Assistance Project of hexu software has achieved remarkable results
- GBase 8c 模式可见性查询函数(一)
- mongodb的多数据源配置
- PHP implements stripe subscription
猜你喜欢

Detectron2 installation based on Anaconda under win10

High number_ Chapter 2 differential calculus of multivariate functions__ Geometric application of partial derivatives_ Tangent and normal plane of space curve

Method of C language annotation

Flutter | the easiest way to add header and footer to listview

【Android Kotlin】Property、Getter 和 Setter

Difference between data index and label system of data warehouse

English grammar_ Demonstrative pronoun - so

Take stock of 10 new layer1 to prepare for the next bull market

Multi data source configuration of mongodb

IIS deployment.Netcore
随机推荐
Educational Codeforces Round 132 (Rated for Div. 2)(A-D)
分布式之 CAP 原则
采坑websocket总结
Blockbuster | certik: Web3.0 industry safety report release in the second quarter of 2022 (PDF download link attached)
Gbase 8C access authority query function (6)
【语音合成】TensorFlowTTS 中文文本转语音
采坑websocket總結
Inode, soft link, hard link
数据模型设计方法概述
Application of encryption technology
Gbase 8C access authority query function (I)
书写SQL必养成的好习惯
Gbase 8C session information function (V)
《天幕红尘》笔记与思考(五)强势文化与弱势文化
Blog expression Encyclopedia
Résumé du websocket minier
Gbase 8C system table information function (II)
Summarize the plan, clarify the direction, concentrate and start a new situation -- the Counterpart Assistance Project of hexu software has achieved remarkable results
The prediction of domestic AI protein structure reproduced a breakthrough and solved the 3D structure with a single sequence. Peng Jian's team: "the last piece of puzzle since alphafold2 has been comp
Gbase 8C session information function (I)