C和指针第十六章编程练习

这篇博客主要探讨了C语言中使用Zeller公式进行日期计算的编程练习,包括多个部分的详细实现。作者提到了对某个范围年份对应问题的理解困惑,并参考了相关博客文章进行学习和分享。
摘要由CSDN通过智能技术生成

16.13.1

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[])
{
   
    if(argc < 2)
    {
   
        perror("argc");
        exit(1);
    }
    int i;
    long num = strtol(argv[1], NULL, 10);
    for(i = 2; i < 37 && strtol("29", NULL, i) <= num; i++);
    printf("这个最小基数为%d\n", i - 1);
    return 0;
}

16.13.2

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
   
    srand((unsigned int)time(NULL));
    int num = rand() % 6 + 1;
    printf("您本轮抽取的数字为%d\n", num);
    return 0;
}

16.13.3

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
int main(void)
{
   
    char str[30], * temp = str;
    time_t tim;
    time(&tim);
    strcpy(str, ctime(&tim));
    if(*(temp + 11) == '0')
        printf("当前时针在%c上面,", *(temp + 12));
    else
        printf("当前时针在%c%c上面,", *(temp + 11), *(temp + 12));
    if(*(temp + 14) == '0')
        printf("当前分针在%c上面\n", *(temp + 15));
    else
        printf("当前时针在%c%c上面\n", *(temp + 14), *(temp + 15));
    return 0;
}

16.13.4
用的Zeller公式 至于他说的这个对应哪个范围年份没搞懂是什么意思

#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值