• 实验 1 熟悉C语言编程环境


    // *************** 
    
    // 刘睿
    
    // 130710136
    
    // 打印一颗心的图案 
    
    // *************** 
    
    #include<stdio.h> 
    int main() 
    { 
        printf("   * * *      * * *
    "); 
        printf("  *      *  *      *
    "); 
        printf("*         *          *
    "); 
        printf("  *                *
    "); 
        printf("   *             *
    "); 
        printf("     *          *
    "); 
        printf("       *      *
    "); 
        printf("         *  *
    "); 
        printf("          *
    "); 
    
        return 0; 
    
    } 

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

    #include<stdio.h> #include<stdlib.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); /*本月的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 option=1;      char ch;      int year,month,day;
    
         while (1) {           printf("
     请输入你要打印的年份(XXXX)");
    
        scanf_s("%d",&year);           PrintAllYear(year);           printf("
     还要继续打印吗?(Y/N)
    ");
    
        scanf_s("
    %c",&ch);           if (ch=='N'||ch=='n') break;      }
    
         return 0; }

  • 相关阅读:
    hadoop集群无法找到datanode节点问题解决
    Startup.A51说明(上)
    UCOSII基础之数据结构
    FPGA之难度
    UCOSII学习笔记【二】
    (转)PCB中各层的含义(protel中)
    UCOSII学习笔记 一
    查看51汇编,解决奇怪的问题
    滑雪
    HMM的理解
  • 原文地址:https://www.cnblogs.com/laurenliu1994/p/3355905.html
Copyright © 2020-2023  润新知