求一道c语言程序设计题 2010年12个月的输出,按照所对应的星期输出

急急!!!!!

#include"stdio.h"
void main()
{
int year=0;
int count=0;
int i,j;
long daysfrom1900=0;//19001月1日为星期一
char flag='y';
int a[12]={31,28,31,30,31,30,31,30,31,31,30,31};
int b[12]={31,29,31,30,31,30,31,30,31,31,30,31};
printf("请输入年份\n");
scanf("%d",&year);
if(year%4==0&&year%100!=0||year%400==0)
{
printf("你的年份为闰年!\n");
count=366;
}
else
{
printf("你的年份为平年!\n");
count=365;
}
for(i=1900;i<year;i++)
{
if(year%4==0&&year%100!=0||year%400==0)
daysfrom1900=daysfrom1900+366;
else
daysfrom1900=daysfrom1900+365;
}
printf("%d",daysfrom1900);
for(i=0;i<12;i++)
{
printf("月份%d\n",i+1);
if(count==365)
{
printf(" 星期一 星期二 星期三 星期四 星期五 星期六 星期天\n");
for(j=0;j<a[i];j++)
{
if(flag=='y')
{
if(daysfrom1900%7==1)
{
printf(" ");
printf("%d ",j+1);
}
if(daysfrom1900%7==2)
{
printf(" ");
printf("%d ",j+1);
}
if(daysfrom1900%7==3)
{
printf(" ");
printf("%d ",j+1);
}
if(daysfrom1900%7==4)
{
printf(" ");
printf("%d ",j+1);
}
if(daysfrom1900%7==5)
{
printf(" ");
printf("%d ",j+1);
}
if(daysfrom1900%7==6)
{
printf(" ");
printf("%d ",j+1);
}
if(daysfrom1900%7==0)
{
printf(" ");
printf("%d\n",j+1);
}
flag='n';
daysfrom1900++;
}
else
{

printf(" %3d ",j+1);
if(daysfrom1900%7==0)
printf("\n");
daysfrom1900++;
}

}
flag='y';
}
if(count==366)
{
printf(" 星期一 星期二 星期三 星期四 星期五 星期六 星期天\n");
for(j=0;j<b[i];j++)
{
if(flag=='y')
{
if(daysfrom1900%7==1)
{
printf(" ");
printf("%d ",j+1);
}
if(daysfrom1900%7==2)
{
printf(" ");
printf("%d ",j+1);
}
if(daysfrom1900%7==3)
{
printf(" ");
printf("%d ",j+1);
}
if(daysfrom1900%7==4)
{
printf(" ");
printf("%d ",j+1);
}
if(daysfrom1900%7==5)
{
printf(" ");
printf("%d ",j+1);
}
if(daysfrom1900%7==6)
{
printf(" ");
printf("%d ",j+1);
}
if(daysfrom1900%7==0)
{
printf(" ");
printf("%d\n",j+1);
}
flag='n';
daysfrom1900++;
}
else
{

printf(" %3d ",j+1);
if(daysfrom1900%7==0)
printf("\n");
daysfrom1900++;
}

}
flag='y';
}
printf("\n");
}
}
温馨提示:内容为网友见解,仅供参考
第1个回答  2010-06-30
保证你喜欢我的程序!!!

#include <stdio.h>
int main()
{
int yj[6][7];
int i,j;
int a,n=1;

printf("请问1号是星期几(数字输入):");
scanf("%d",&a);
if(a!=7)
{
for(j=0;j<a;j++)
{
yj[0][j]=0;
}
for(j=a;j<7;j++)
{
yj[0][j]=n;
n++;
}
for(i=1;i<6;i++)
for(j=0;j<7;j++)
{
if(n==32)
goto end;
yj[i][j]=n;
n++;
}
}
else
{
n=1;
for(i=0;i<6;i++)
for(j=0;j<7;j++)
{
if(n==32)
goto end;
yj[i][j]=n;
n++;
}
}
end:
printf("日\t一\t二\t三\t四\t五\t六\n");
for(i=0;i<6;i++)
{
for(j=0;j<7;j++)
{
if(yj[i][j]==31)
{
printf("%d\t",yj[i][j]);
getchar();
return 0;
}
if( yj[i][j]!=0)
printf("%d\t",yj[i][j]);
else
printf(" \t");
}
printf("\n");
}
return 0;
}

谢谢采纳~~希望对你有帮助本回答被提问者采纳
第2个回答  2010-07-01
#include<iostream>
#include<iomanip>
using namespace std;
void main()
{
int d[]={31,28,31,30,31,30,31,31,30,31,30,31};
int x=5,day,y;
char m[][20]={"january","february","march","april","may","june","july","august","september","october","november","december"};
char w[][20]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
for(int i=0;i<12;i++)
{
cout<<m[i]<<endl;
for (int j=0;j<7;j++)
cout<<setw(10)<<w[j];
cout<<endl;
for(y=1;y<=x;y++)
cout<<setw(10)<<' ';
for (day=1;day<+d[i];day++)
{

cout<<setw(10)<<day;
if(x<=6) x++;
else {x=0,cout<<endl;}
}
cout<<endl;
}
}
第3个回答  2010-06-30
//---------------------------------------------------------------------------

#include <stdio.h>
int isp(const int y)
{
return y%4==0&&y%100||y%400==0;
}
void prtmth(int y,int m) /*输出公元y年m月的月历*/
{
int i,fd,yy=y,mm=m,d;
char *mnm[]={"January","February","March","April","May","June","July","August","September","October","November","December"};
if (mm<3) {
mm+=12;
yy--;
}
fd=(1+2*mm+3*(mm+1)/5+yy+yy/4-yy/100+yy/400+1)%7;
printf("****************%s*******************\n",mnm[m-1]);
printf("Sun\tMon\tTues\tWed\tThur\tFri\tSat\n");
switch (m) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: d=31; break;
case 4:
case 6:
case 9:
case 11:d=30;break;
case 2:d=isp(y)?29:28;break;
}
for (i = 0; i<fd; i++) {
printf("\t");
}
for (i=1; i<=d; i++) {
printf("%2d\t",i);
if ((i+fd)%7==0)
putchar('\n');

}

putchar('\n');
putchar('\n');
}
int main(void)
{
int i;
for (i=1; i<=12; i++) {
prtmth(2010,i);
}

return 0;
}
//---------------------------------------------------------------------------

求一道c语言程序设计题 2010年12个月的输出,按照所对应的星期输出
void main(){ int year=0;int count=0;int i,j;long daysfrom1900=0;\/\/19001月1日为星期一 char flag='y';int a[12]={31,28,31,30,31,30,31,30,31,31,30,31};int b[12]={31,29,31,30,31,30,31,30,31,31,30,31};printf("请输入年份\\n");scanf("%d",&year);if(...

c语言设计万年历 输入任意年份,输出该年12个月份 输入任意年份月份...
struct tm *date; int year,m; while(1) { printf("输入任意年份及月份:\\n"); scanf("%d%d",&year,&m); if(m<1 || m>12) { printf("月份超出范围,重新输入!\\n"); continue; } mon=m; break; } date=getDate(year,mon);...

用c语言输入日期输出星期几
include <stdio.h>int main(int argc, char const *argv[]){int data;scanf("%d",&data);printf("星期%d\\n",(data +1)%7 + 1);return 0;}

C语言编程序实现如下功能:输入任意一个日期的年、月、日的值,求出是...
else if (m==9) c=31 28 31 30 31 30 31 31 d; else if (m==10) c=31 28 31 30 31 30 31 31 30 d; else if (m==11) c=31 28 31 30 31 30 31 31 30 31 d; else if (m==12) c=31 28 31 30 31 30 31 31 30 31 30 d; if (m>2) {if (y0==0) {if (y@0=...

C语言的问题:根据输入的年月日,输出该日为该年度的第几周、第几天、星...
\/\/根据输入的年月日,输出该日为该年度的第几周、第几天、星期几。\/\/如输入: 2007,12,1 \/\/则输出: 48z,335t,6xq int date[12]={31,28,31,30,31,30,31,31,30,31,30,31};include<stdio.h> int Check(int a,int b,int c);\/\/判断输入的合法性 int CountWeek(int a,int ...

跪求C语言万年历程序设计
include char* month_str[]={"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"};char* week[]={"星期一","星期二","星期三","星期四","星期五","星期六","星期天"};int IsLeapYear(int year){ if((year%4==0&&year%100!=0...

c语言课程设计,关于年历显示。下面是要求: (1) 输入一个年份,输出是在...
int firstweek; \/\/每个月份第一天,星期几。int line =0;scanf("%d",&inputyear);if(isLeapYear(inputyear)){ monthday[1]++;} printf("*** %d ***\\n",inputyear);for(i = 0;i<12;i++) \/\/先一个月份一个月份的输出。{ printf("\\n===\\n");printf("%s\\n",monthname[i]...

C语言,输入年月日,输出星期几
case 12:t+=31;break;} } return t;} void inputCheck(int year,int month,int day){ if(year<0)printf("input is wrong!\\n");else { switch(month){ case 2:if(day>28 && (!((year%4==0 && year%100!=0) || (year%400==0)))printf("input is wrong!\\n");if(day>...

用C语言编写一个程序,将输入的英文星期单词转化为中文输出
include <stdio.h>#include <string.h>char *weeks[]={"Monday","Tuesday","Wednesday","Thursday","Friday", "Saturday","Sunday"};char *trans[]={"星期一","星期二","星期三","星期四","星期五","星期六","星期日"};void translate(char *pstr){int i;for(i=0;i<7;i++){...

C语言中如果从键盘上输入一个代表星期几的数值(整数),根据下面的对应关 ...
用一个指针数组存放汉字"一"到"日"字符串的指针,可用简单代码解决这问题。举例如下:\/\/#include "stdafx.h"\/\/If the vc++6.0, with this line.#include "stdio.h"int main(void){ char *pw[7]={"一","二","三","四","五","六","日"},w; while(1){ printf("Input...

相似回答
大家正在搜