1.判断是否是闰年:

#include <stdio.h>

int main(void)
{
    int year, a;
    printf("Please enter the year:\n");
    scanf("%d",&year);
    if (year % 400 == 0)
        a = 1;
    else
    {
        if (year % 4 == 0 && year % 100 != 0)
            a = 1;
        else
            a = 0;
    }
    if (a == 1)
        printf("%d is a leap year\n", year);
    else
        printf("%d not a leap year\n", year);
    return 0;
}

2.判断一个日期是周几,有两种算法

 1 #include "stdio.h"
2 int day_of_week1(int y, int m, int d)//使用的是蔡勒公式
3 {
4     if (m < 3)
5     {
6         y--;
7         m += 12;
8     }
9     return ((y%100+(y%100)/4+(y/100)/4-2*(y/100)+(26*(m+1))/10+d-1)%7);
10 }
11
12 int day_of_week2(int y, int m, int d)//
13 {
14     int t[12]={0,3,2,5,0,3,5,1,4,6,2,4};
15     y -= m < 3;
16     return ((y + y / 4 - y / 100 + y / 400 + t[m - 1] + d) % 7);
17 }
18
19 int main(void)
20 {
21     int a = 3, y=2020, m=1, d=1, w1 = 0,w2;
22     printf("%d-%d-%d\n", y, m, d);
23     w1 = day_of_week1(y, m, d);
24     printf("星期%d", w);
25 w2 = day_of_week2(y, m, d);
26     printf("星期%d", w);
27     return 0;
28 }

3.打印心代码(转自一位不知道的大佬)

 1 #include "stdio.h"
2 #include <math.h>
3 float f(float x, float y, float z)
4 {
5     float a = x * x + 9.0f / 4.0f * y * y + z * z - 1;
6     return a * a * a - x * x * z * z *z- 9.0f / 80.0f * y * y * z * z * z;
7 }
8 float h(float x, float z)
9 {
10     for (float y = 1.0f; y >= 0.0f; y -= 0.001f)
11         if (f(x, y, z) <= 0.0f)
12             return y;
13     return 0.0f;
14 }
15 int main(void)
16 {
17     for (float z = 1.5f; z > -1.5f; z -= 0.05f)
18     {
19         for (float x = -1.5f; x < 1.5f; x+= 0.025f)
20         {
21             float v = f(x, 0.0f, z);
22             if(v <= 0.0f)
23             {
24                 float y0 = h(x,z);
25                 float ny = 0.01f;
26                 float nx = h(x + ny, z) - y0;
27                 float nz = h(x, z+ny) - y0;
28                 float nd = 1.0f /sqrtf(nx*nx + ny*ny + nz*nz); 
29                 float d = (nx+ny-nz) * nd *0.5f + 0.5f; 
30                 putchar(".:-=+*#%@"[(int)(d*5.0f)]);
31             }
32             else 
33                 putchar(' ');
34         }
35         putchar(' ');
36     }
37     for (int i = 5; i >0;){}
38 }

4.这个建议自己试试,很好玩。

#include <stdio.h>
#include <stdlib.h>
#define decode(p,r,i,n,t,f) r##f##r##i##t##p
#define puts decode(m,s,t,o,e,y)
int main()
{
    puts((char*)(const double[]){1.3553894309652565e+224,6.952439113111912e-308});
    return 0;
}

最新文章

  1. DBCP 配置备注
  2. [bzoj1269][AHOI2006文本编辑器editor] (splay模版题 or pb_ds [rope]大法)
  3. HTML &lt;input type=&quot;file&quot;&gt;上传文件——结合asp.net的一个文件上传示例
  4. HDU 查找最大元素 2025
  5. Android view的requestLayout()
  6. cvThreshold
  7. 在eclipse中安装activiti插件
  8. Scala:(1)变量
  9. Android应用开发基础篇(13)-----GestureDetector(手势识别)
  10. SDL 开发实战(一):SDL介绍及开发环境配置
  11. ArrayList的ConcurrentModificationException异常和多线程下的异常
  12. [debug]记一次竞态更新bug的解决
  13. 洛谷P4707 重返现世 [DP,min-max容斥]
  14. 03-封装BeanUtil工具类(javabean转map和map转javabean对象)
  15. jsonp原理及同源策略
  16. 关于 web 页面 占满全屏
  17. 列表与for循环
  18. Win10系统电脑桌面图标没有了怎么办
  19. IIS_部署出错
  20. RxJava2.0学习笔记1 2018年3月23日 星期五

热门文章

  1. LocalDateTime 使用记录
  2. C# RichTextBox跳转到指定行(文本行跳转和显示行跳转)
  3. pkill 直接对进程对名字进行操作,可以同时杀死多个进程。
  4. VS Code编写stm32
  5. dcloud打包安卓隐私政策上架问题!
  6. Mac连接交换机
  7. 在windows上远程linux (待完善)
  8. dev gridControl控件 常用使用方法及设置(实时更新)
  9. IIS管理器中远程管理其它web服务器上的IIS站点
  10. Android Studio: how to remove/update the “Created by” comment added to all new classes?