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

// *************** 

// 刘睿

// 130710136

// 打印一颗心的图案 

// *************** 

#include<stdio.h> 
int main() 
{ 
    printf("   * * *      * * *\n"); 
    printf("  *      *  *      *\n"); 
    printf("*         *          *\n"); 
    printf("  *                *\n"); 
    printf("   *             *\n"); 
    printf("     *          *\n"); 
    printf("       *      *\n"); 
    printf("         *  *\n"); 
    printf("          *\n"); 

    return 0; 

} 

#include<stdio.h>

int main()

{

    printf("*******************************************              \n");
    printf("*******************************************              \n");
    printf("**          ***           ***            **              \n");
    printf("**        ***               ***          **              \n");
    printf("**      ***                   ***        **              \n");
    printf("**    ***                       ***      **              \n");
    printf("**  ***                           ***    **              \n");
    printf("*****                                 *****              \n");
    printf("**                                       **              \n");                     
    printf("**         ****************              **              \n");
    printf("**         *              *              **              \n");
    printf("**         *              *              **              \n");
    printf("**         *              *              **              \n");
    printf("**         *              *              **              \n");
    printf("**         *              *              **              \n");
    printf("**         *              *              **              \n");
    printf("*******************************************              \n");
    printf("*******************************************              \n");


    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("\n\n                                                     %d Calander\n",year);       for(i=1;i<=12;i++) {

             printf("\n\n                                    %s\n\n",month_str[i-1]);              printf("星期一 星期二 星期三 星期四 星期五 星期六 星期日\n");              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("\n");              }       }

      return 0; }

int main() {        int option=1;      char ch;      int year,month,day;

     while (1) {           printf("\n 请输入你要打印的年份(XXXX)");

    scanf_s("%d",&year);           PrintAllYear(year);           printf("\n 还要继续打印吗?(Y/N)\n");

    scanf_s("\n%c",&ch);           if (ch=='N'||ch=='n') break;      }

     return 0; }

 

 

 

posted @ 2013-10-07 19:55  刘睿1994  阅读(260)  评论(0编辑  收藏  举报