C语言 百炼成钢2
//题目4:输入某年某月某日,判断这一天是这一年的第几天? #define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h> //分析:某年决定是平年还是闰年,某月决定本月有多少天,最后结果是前几个月的时间+本月已过的天数
//闰年的判断 (year%4==0&&year%100!=0)||(year%400==0) int protect(int year, int month){
//year==1表示闰年,year=0表示平年
int res = ;
int tuemonth = ;
if (year)
{
tuemonth = ;
}
switch (month - )
{
case :
res = ;
break;
case :
res = ;
break;
case :
res = + tuemonth;
break;
case :
res = + tuemonth + ;
break;
case :
res = + tuemonth + + ;
break;
case :
res = + tuemonth + + + ;
break;
case :
res = + tuemonth + + + + ;
break;
case :
res = + tuemonth + + + + + ;
break;
case :
res = + tuemonth + + + + + + ;
break;
case :
res = + tuemonth + + + + + + + ;
break;
case :
res = + tuemonth + + + + + + + + ;
break;
case :
res = + tuemonth + + + + + + + + + ;
break;
default:
res = + tuemonth + + + + + + + + + + ;
break;
}
return res;
} void main(){
int year = ;
int month = ;
int day = ;
int res = ;
printf("请输入年月日!\n");
scanf("%d,%d,%d", &year,&month,&day);
//
//判断年
if ((year % == && year % != ) || (year % == ))
{
//判断该年是闰年,二月份有29天
res = protect(, month) + day;
}
else
{
res = protect(, month) + day;
}
printf("这一天是这一年的第%d天", res); system("pause");
}

//题目5:输入三个整数x,y,z,请把这三个数由小到大输出。 #define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h> void sortnum(int *x,int *y,int *z){
int temp = ;
if (*x>*y)
{
temp = *x;
*x = *y;
*y = temp;
}
if (*y>*z)
{
temp = *z;
*z = *y;
*y = temp;
}
//至此*z的数值最大
if (*x>*y)
{
temp = *x;
*x = *y;
*y = temp;
}
//至此*x的数值最小
} void main(){
int x, y, z;
int *px, *py, *pz;
px = &x;
py = &y;
pz = &z;
scanf("%d%d%d", px, py, pz);
printf("\n你输入的数据是X=%d;Y=%d;Z=%d", *px, *py, *pz);
sortnum(px, py, pz);
printf("\n你排序之后的数据是X=%d;Y=%d;Z=%d", *px, *py, *pz); system("pause");
}

//题目6:用*号输出圆形图案。 #define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<math.h> //分析;(x1-x2)^2+(y1-y2)^2=R^2;其中r是园的半径,(x1-x2)^2+(y1-y2)^2是获取一个点与园心坐标的距离
//本题假设r=10,圆心坐标就是(10,0)
//pow() 函数用来求 x 的 y 次幂(次方),其原型为:double pow(double x, double y); //本圆不圆,是因为屏幕的行间距和列间距不相等 void main(){
//上方y轴
for (int i = ; i >-; i--)
{
//左侧x轴
for (int j = ; j < ; j++)
{
if ((pow((j - ),2.0)+pow(i,2.0))==pow(10.0,2.0))
{
printf("*");
}
else{
printf(" ");
}
}
//右侧x轴
for (int j = ; j < ; j++)
{
if ((pow((j - ), 2.0) + pow(i, 2.0)) == pow(10.0, 2.0))
{
printf("*");
}
else{
printf(" ");
}
}
printf("\n");
}
system("pause");
}

C语言 百炼成钢2的更多相关文章
- C语言 百炼成钢19
/* 题目55: 有一个字符串符合以下特征(”abcdef,acccd,eeee,aaaa,e3eeeee,sssss,";),要求写一个函数(接口),输出以下结果 1) 以逗号分割字符串, ...
- C语言 百炼成钢3
//题目7:用*号输出空心菱形图案 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> # ...
- C语言 百炼成钢1
//题目:有1.2.3.4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> ...
- C语言 百炼成钢18
//题目52:用递归打印以下图形 //* //*.*. //*..*..*.. //*...*...*...*... //*....*....*....*....*.... #include<s ...
- C语言 百炼成钢17
//题目49:老师将糖果分成若干份,让学生按任意次序领取,第一个领取的,得到1份加上剩余糖果的1/10, //第二个领取的,得到2份加上剩余糖果的1/10,第三个领取的,得到3份加上剩余糖果的1/10 ...
- C语言 百炼成钢16
//题目46:海滩上有一堆桃子,五只猴子来分.第一只猴子把这堆桃子凭据分为五份,多了一个,这只 //猴子把多的一个扔入海中,拿走了一份.第二只猴子把剩下的桃子又平均分成五份,又多了 //一个,它同样把 ...
- C语言 百炼成钢15
//题目43:有n个人围成一圈,顺序排号.从第一个人开始报数(从1到3报数),凡报到3的人退出 //圈子,问最后留下的是原来第几号的那位. #include<stdio.h> #inclu ...
- C语言 百炼成钢14
//题目40:输入3个数a,b,c,按大小顺序输出.(使用指针完成) #include<stdio.h> #include<stdlib.h> //分析:用指针完成,说明不可以 ...
- C语言 百炼成钢13
//题目37:将一个数组逆序输出.用第一个与最后一个交换. #include<stdio.h> #include<stdlib.h> #include<math.h> ...
随机推荐
- 【转】一个非常常见但容易被忽略的c++问题——用IPML模式可以解决
pimpl (the pointer-to-implementation idiom)手法在 C++ 里已是“高手”们广泛运用的成熟方法之一,它的优点很多,诸如降低编译依赖.提高重编译速度之类的工具性 ...
- 如何获取QQ里的截图app?
电脑系统平台:OS X EI Capitan 10.11 在以前的旧的QQ版本,QQ的截图的偏好还有一个开机自启动的选项: 现在新的版本,却没有了"开机自动运行"的选项,然而有时候 ...
- iOS 中二维码扫描
随着微信的大量推广,越来越多的人会在生活中用到二维码这一个方便大家的功能. 因此,很多的app中也逐渐的都加入了二维码这个元素,今天先给大家介绍一下iOS7后系统自带自己可以手动设计的二维码扫描. Q ...
- Git基本使用命令
整理Git的一些基本使用命令. # 1)克隆代码 boldseas@lian-PC MINGW64 /d/TestGroup $ git clone ssh://git@code.boldseas ...
- 【重构】 利用 cos 组件实现jsp中上传附件
利用JSP&Servlet重构项目 利用 cos 组件实现jsp中上传附件 fileUpload.jsp --> FileUploadController.java --> fil ...
- PowerDesigner执行SQL生成模型
PowerDesigner版本:15.2.0 步骤如下: 1.打开PowerDesigner软件如下图: 2.选择:File->Reverse Engineer->Database... ...
- JodaTime library not available - @DateTimeFormat not supported
使用spring的@DateTimeFormat来格式化Date类型时,报错: org.springframework.validation.BindException: org.springfram ...
- 你所不知道的SQL Server数据库启动过程(用户数据库加载过程的疑难杂症)
前言 本篇主要是上一篇文章的补充篇,上一篇我们介绍了SQL Server服务启动过程所遇到的一些问题和解决方法,可点击查看,我们此篇主要介绍的是SQL Server启动过程中关于用户数据库加载的流程, ...
- Tomcat报java.lang.ClassNotFoundException: 1catalina.org.apache.juli.FileHandler
最近在生产环境部署Tomcat的时候,在启动的时候,在控制台报"java.lang.ClassNotFoundException: 1catalina.org.apache.juli.Fil ...
- openssl c_rehash
一.简介 c_rehash 为文件创建一个符号连接,并将此符号连接的名称设为文件的hash值,作用是让openssl在证书目录中能够找到证书. 二.语法 c_rehash [-old] [-h] [- ...