| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 688 人关注过本帖
标题:哪位朋友把下面的程序,复制下去调试一下看看错误,然后给我回复一下。
只看楼主 加入收藏
苏明亮
Rank: 2
等 级:论坛游民
帖 子:20
专家分:36
注 册:2009-8-26
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:6 
哪位朋友把下面的程序,复制下去调试一下看看错误,然后给我回复一下。
#include <stdio.h>
#include <bios.h>
#include <dos.h>
#include <conio.h>
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
#define PAGEUP 0x4900
#define PAGEDOWN 0x5100
#define QLOWER 0x1071
#define QUPPER 0x1051
#define SPACE 0x3920
#define ESC 0x011b
struct date sysTime;
int currentYear;
int currentMonth;
int currentDay;
int n_currentMon;
int n_lastMon;
void checkDate();
int isLeapyear(int year);
int getWeek(int year,int month,int day);
void printSpace(int n);
void printSparator();
void printUsage();
void printWeek();
void printWeek2(int week);
void showCalendar(int year,int month,int day);
void getkeyValue();
void checkDate()
{
 if(currentYear<=0)
{
 gotoxy(1,27);
printf("The year should be a positve number !\n");
gotoxy(1,28);
printf("Press any key to continue .......");
getchar();
getchar();
currentYear=sysTime.da_year;
currentMonth=sysTime.da_mon;
currentDay=sysTime.da_day;
}
if(currentMonth>12||currentMonth<1)
{
gotoxy(1,27);
printf("The month should be an number between 1 and 12 !\n");
gotoxy(1,28);
printf("Press any key to continue......");
getchar();
getchar();
currentYear=sysTime.da_year;
currentMonth=sysTime.da_mon;
currentDay=sysTime.da_day;
}
if(currentDay>31||currentDay<1)
{
gotoxy(1,27);
printf("The day should be a nomber between 1 and 31 !\n");
gotoxy(1,28);
printf("Press any key to continue......");
getchar();
getchar();
currentYear=sysTime.da_year;
currentMonth=sysTime.da_mon;
currentDay=sysTime.da_day;
}
}
int isLeapyear( int year)
{
if(year%4==0&&year%100||year%400==0)
return 1;
else
return 0;
}
int getWeek(int year,int month,int day)
{
int leapFlag;
int week;
int i;
int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int count=0;
leapFlag=isLeapyear(year);
if(leapFlag==1)
a[2]++;
for(i=1;i<month;i++)
{
count+=a[i];
}
count+=day;
week=(year+1+(year-1)/4+(year-1)/100+(year-1)/400+count)%7;
return week;
}
void printSpace(int n)
{
int i;
for(i=0;i<n;i++)
printf(" ");
}
void printfSeparetor()
{
int i;
for(i=0;i<38;i++)
{
printf("=");
}
printf("\n");
}
void printfUsage()
{
gotoxy(45,3);
textcolor(YELLOW);
cprintf("------------Usage-----------");
gotoxy(45,5);
textcolor(YELLOW);
cprintf("YEAR");
gotoxy(50,5);
printf(" Up key() to increase;\n");
gotoxy(50,7);
printf("Down key() to decrease.\n");
gotoxy(45,9);
textcolor(YELLOW);
cprintf("MONTH:");
gotoxy(50,9);
printf(" Right key () to incerase;\n");
gotoxy(50,11);
printf("Left key() to decreasr.\n");
gotoxy(45,13);
textcolor(YELLOW);
cprintf("DAY");
gotoxy(50,13);
printf(" PageDown key to increase;\n");
gotoxy(50,15);
printf(" PageUp key to decrease.\n");
gotoxy(45,17);
textcolor(YELLOW);
cprintf("QUERY");
gotoxy(50,17);
printf("Q/q key\n");
textcolor(YELLOW);
gotoxy(45,19);
cprintf("RESET");
gotoxy(50,19);
printf(" SPACE key.\n");
gotoxy (45,21);
textcolor(YELLOW);
cprintf("EXIT");
gotoxy(50,21);
printf("Esc key\n");
gotoxy(59,5);
_CX=01;
_AH=0xa;
_AL=24;
geninterrupt(0x10);
gotoxy(61,7);
_CX=01;
_AH=0xa;
_AL=25;
geninterrupt(0x10);
gotoxy(62,9);
_CH=01;
_AH=0xa;
_AL=26;
geninterrupt(0x10);
gotoxy(61,11);
_CX=01;
_AH=0xa;
_AL=27;
geninterrupt(0x10);
textcolor(7);
}
void printWeek()
{
int day;
day=getWeek(currentYear,currentMonth,currentDay);
textcolor(11);
if(day==0)
cprintf("%d-%d-%d,Sunday!",currentYear,currentMonth,currentDay);
if(day==1)
cprintf("%d-%d-%d,Monday!",currentYear,currentMonth,currentDay);
if(day==2)
cprintf("%d-%d-%d,Tuesday!",currentYear,currentMonth,currentDay);
if(day==3)
cprintf("%d-%d-%d,Wednesday!",currentYear,currentMonth,currentDay);
if(day==4)
cprintf("%d-%d-%d,Thurday!",currentYear,currentMonth,currentDay);
if(day==5)
cprintf("%d-%d-%d,Friday!",currentYear,currentMonth,currentDay);
if(day==6)
cprintf("%d-%d-%d,Saturday!",currentYear,currentMonth,currentDay);
textcolor(7);
}
void printfWeek2(int week)
{
if(week==0)
cprintf(",Sunday");
if(week==1)
cprintf(",Monday");
if(week==2)
cprintf(",Tuesday");
if(week==3)
cprintf(",Wendesday");
if(week==4)
cprintf(",Thurday");
if(week==5)
cprintf(",Friday");
if(week==6)
cprintf(",Staturday");
}
void showCalendar(int year,int month,int day)
{
int i;
int j;
int outDay;
int leapFlag;
int dayLastMon;
int week;
int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
outDay=0;
dayLastMon=0;
week=0;
leapFlag=isLeapyear(year);
if(leapFlag==1)
{
a[2]++;
}
if(day>a[month])
{
printf("The number of this month's day is %d at most !\n",a[month]);
printf("press any key to continue......\n");
getchar();
getchar();
year=sysTime.da_year;
month=sysTime.da_mon;
day=sysTime.da_day;
currentYear=sysTime.da_year;
currentMonth=sysTime.da_mon;
currentDay=sysTime.da_day;
}
n_currentMon=a[month];
n_lastMon=a[month-1];
week=dayLastMon=getWeek(year,month,1);
clrscr();
printf("\nThe calendar of %d",year);
textcolor(10);
if(leapFlag==1)
cprintf("[leap year]",year);
if(leapFlag==0)
cprintf("[not leap year]",year);
printf("\n");
textcolor(7);
printSeparator();
textcolor(YELLOW);
switch(month)
{
case 1: cprintf("January 1 "); break;
case 2: cprintf("February 2 "); break;
case 3: cprintf(" March 3 "); break;
case 4: cprintf(" April 4"); break;
case 5: cprintf(" May  5"); break;
case 6: cprintf(" June 6"); break;
case 7: cprintf(" July 7 "); break;
case 8: cprintf(" August 8 "); break;
case 9: cprintf(" September 9 "); break;
case 10: cprintf(" October 10 "); break;
case 11: cprintf(" November 11 "); break;
case 12: cprintf(" December 12"); break;
}
textcolor(7);
printf("\n\n");
textcolor(13);
cprintf(" Sun Mon Tue Wed Thu Fri Sat");
textcolor(7);
printf("\n\n");
for(i=0;i<6;i++)
{
if(i==0)
{
printSpace(dayLastMon*4);
for(j=0;j<7-dayLastMon;j++)
{
if(outDay==day-1)
{
textcolor(YELLOW);
cprintf("[%d]",++outDay);
textcolor(7);
}
else if(outDay==day &&week!=0)
{
printf("%3d",++outDay);
}
else
{
printf("%4d",++outDay);
}
week=(week<6)? week+1:0;
}
printf("\n\n");
}
else
{
for(j=0;j<7;j++)
{
if(outDay<a[month])
{
if(outDay==day-1)
{
if(outDay<9)
{textcolor(YELLOW);
cprintf("[%d]",++outDay);
textcolor(7);
}
else
{
textcolor(YELLOW);
cprintf(" [%2d",++outDay);
textcolor(7);
}
}
else if(outDay==day&& week!=0)
{
printf("3d",++outDay);
}
else
{
printf("%4d",++outDay);
}
}
week=(week<6)?week+1:0;
}
printf("\n\n");
if(outDay==a[month])
break;
}
}
printSeparator();
printf("The day you choose is: \n\n");
printWeek();
gotogxy(1,22);
tectcolor(10);
cprintf("-------------------------------\n");
textcolor(7);
printf("\nToday is:%d-%d-%d",sysTime.da_year,sysTime.da_mon,sysTime.da_day);
printWeek2(getWeek(sysTime.da_year,sysTime.da_mon,sysTime.da_day));
printf("\n\n");
printUsage();
gotoxy(1,25);
}
void getKeyValue()
{
int key;
char ch;
currentYear=sysTime.da_year;
currentMonth=sysTime.da_mon;
currentDay=sysTime.da_day;
showCalendar(currentYear,currentMonth,currentDay);
while(1);
{
key=bioskey(0);
if(key==RIGHT)
{
if(currentMonth<12 && currentMonth>=1)
{
currentMonth++;
}
else
{
currentYear++;
currentMonth=1;
}
}
if(key==LEFT)
{
if(currentMonth<=12 && currentMonth>1)
{
currentMonth--;
}
else
{
currentYear--;
currentMonth=12;
}
}
if(key==UP)
{
currentYear++;
}
if(key==DOWN)
{
currentYear--;
}
if(key==PAGEUP)
{
if(currentDay!=1)
{
currentDay--;
}
else if(currentDay==1 && currentMonth==1)
{
currentYear--;
currentMonth=12;
currentDay=31;
}
else
{
currentMonth--;
currentDay=n_lastMon;
}
}
if(key==PAGEDOWN)
{
if(n_currentMon!=currentDay)
{
currentDay++;
}
else if (n_currentMon==currentDay && currentMonth==12)
{
currentYear++;
currentMonth=1;
currentDay=1;
}
else
{currentMonth++;
currentDay=1;
}
}
if(key==QLOWER ||key==QUPPER)
{
{
printf("Input date (eg,%d-%d-%d):",sysTime.da_year,sysTime.da_mon,sysTime.da_day);
scanf("%d-%d-%d",&currentYear,&currentMonth,&currentDay);
checkDate();
}
}
if(key==SPACE)
{
currentYear=sysTime.da_year;
currentMonth=sysTime.da_mon;
currentDay=sysTime.da_day;
}
if(key==ESC)
{
printf("Do you really want to quit?(Y/N)");
ch=getchar();
if(ch=='y'||ch=='Y')
{
     break;
}
}
showCalendar(currentYear,currentMonth,currentDay);
}
}
void main()
{
clrscr();
_AL=03;
_AH=0;
geninterrupt(0x10);
getdate(&sysTime);
getKeyValue();
}
搜索更多相关主题的帖子: 调试 朋友 
2009-08-27 19:04
麻花疼
Rank: 2
等 级:论坛游民
帖 子:167
专家分:36
注 册:2005-12-10
收藏
得分:14 
这代码的格式太难看了,没有缩进

QQ:10000
2009-08-27 19:28
苏明亮
Rank: 2
等 级:论坛游民
帖 子:20
专家分:36
注 册:2009-8-26
收藏
得分:0 
嘿嘿   多多包涵  
2009-08-27 22:35
fgchg911
Rank: 4
等 级:业余侠客
威 望:1
帖 子:131
专家分:204
注 册:2009-9-6
收藏
得分:0 
不用包涵,在vc6.0里,一个ctrl+a,在一个alt+f8就好看了,二楼的自己偷懒
2009-09-12 13:35
fgchg911
Rank: 4
等 级:业余侠客
威 望:1
帖 子:131
专家分:204
注 册:2009-9-6
收藏
得分:0 
Cannot open include file: 'bios.h': No such file or directory
怎么打不开这个文件,我记得好像是在include目录里面,谁能解释下
2009-09-12 13:39
forever74
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:CC
等 级:版主
威 望:58
帖 子:1692
专家分:4282
注 册:2007-12-27
收藏
得分:0 
这种代码对TC有强烈的依赖性,不用试图在其他环境下调试了

对宇宙最严谨的描述应该就是宇宙其实是不严谨的
2009-09-12 14:53
cgaa1
Rank: 2
来 自:uestc
等 级:论坛游民
帖 子:52
专家分:64
注 册:2009-4-11
收藏
得分:0 
楼主这个程序是想实现什么功能呢?
2009-09-12 15:57
快速回复:哪位朋友把下面的程序,复制下去调试一下看看错误,然后给我回复一下。 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024812 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved