zoukankan      html  css  js  c++  java
  • 实验一 熟悉C语言编程环境

    #include<stdio.h>
    #include<stdio.h>
     
    char* month_str[]={"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"};
    int
    mon_day[][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
     
    int IsLeapYear(int year)     /*find out the year is leap year or not*/
    {
        if((year%4==0&&year%100!=0)||(year%400==0))
            return 1;
        else
            return 0;
    }
     
    int DaySearch(int year,int month,int day)/*search what day this day is*/
    {
        int days=0;
        int m,i;
        for (i=1900;i<year;i++)
            if(IsLeapYear(i))days=days+366;
            else days=days+365;
        for(m=1;m<month;m++)
            days=days+mon_day[IsLeapYear(year)][m-1];
        return((int)days%7);
    }
     
    int PrintAllYear(int year)/*print the all year*/
    {
        int temp;
        int i,j;
        printf("
    
                                      %d Calander
    ",year);
        for(i=1;i<=12;i++){
            printf("
    
                         %s
    
    ",month_str[i-1]);
            printf("星期一 星期二 星期三 星期四 星期五 星期六 星期日
    ");
            temp=DaySearch(year,i,1);/*本月的一号是星期几*/
            for(j=1;j<=mon_day[IsLeapYear(year)][i-1]+temp;j++)
            {
                if(j-temp<=0)            printf("            ");
                else if(j-temp<10) printf("%d           ",j-temp);
                    else printf("%d          ",j-temp);
                    if(j%7==0) printf("
    ");
            }
        }
        return 0;
    }
     
    int main()
    {
        int optin=1;
        char ch;
        int year,month,day;
     
        while (1) {
            printf("
    请输入你要打印的年份(XXXX)");
            scanf("%d",&year);
            PrintAllYear(year);
            printf("
    还要继续打印吗?(Y/N)
    ");
            scanf("
    %c",&ch);
            if(ch=='N'||ch=='n')break;
        }
        return 0;
    }
        

    #include <stdio.h>
    int main()
    {
        printf("     ***         ***
    ");
        printf("  *       *   *       *
    ");
        printf("*           *           *
    ");
        printf("  *                   *
    ");
        printf("    *               *
    ");
        printf("      *           *
    ");
        printf("        *       *
    ");
        printf("          *   *
    ");
        printf("            *
    ");
    
        return 0;
    }

  • 相关阅读:
    【Mesh R-CNN】论文翻译(原理部分)
    关于栈的学习记录
    css入门笔记
    前端学习之html基础知识归纳
    navigator url无法跳转跳转问题
    新手小白学会vim脚本配置
    Linux下实现两个变量之间传参
    [Apache Doris] Apache Doris 架构及代码目录解读
    [编程总结] 开源系统平台化建设思路
    论文阅读|PointRend: Image Segmentation as Rendering
  • 原文地址:https://www.cnblogs.com/liyang1995/p/3355900.html
Copyright © 2011-2022 走看看