// *************** // 刘睿 // 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; }