当前位置: 代码迷 >> C语言 >> 关于“大月”和“小月”的问题?
  详细解决方案

关于“大月”和“小月”的问题?

热度:553   发布时间:2007-04-24 11:16:51.0
关于“大月”和“小月”的问题?
任意输入一个数(这个数代表月份),判断它是大月还是小月,帮我看看,问题出在了哪里,不管输入什么都是 number is error.
#include"stdio.h"
int main()
{
int a,A;
scanf("%d",a);
if(a>=1&&a<=12)
{
A=bioskey(0);
switch(A)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: printf("这是大月.\n");break;
default: printf("这是小月.\n");
}
}
else
printf("number is error.\n");
getch();
}
搜索更多相关的解决方案: 小月  case  printf  number  

----------------解决方案--------------------------------------------------------
呵呵!!!!!你会这个A=bioskey(0);
东西吗,还有的就是scanf("%d",&a);看到了吗?你把这个A=bioskey(0);删除了啊,改一下switch(a)就会成功的
----------------解决方案--------------------------------------------------------
#include"stdio.h"
int main()
{
int a;
scanf("%d",a);
if(a>=1&&a<=12)
{
switch(a)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: printf("this is big .\n");break;
default: printf("this is small.\n"); break;
}
}
else printf("number is error.\n");
getch();
}
改了,还是同样的错误
----------------解决方案--------------------------------------------------------
以下是引用ml342418175在2007-4-24 12:04:28的发言:
#include"stdio.h"
int main()
{
int a;
scanf("%d",&a); //漏了这个,还有,你原来的程序没错,只是bioskey()函数要包个头文件bios.h
if(a>=1&&a<=12)
{
switch(a)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: printf("this is big .\n");break;
default: printf("this is small.\n"); break;
}
}
else printf("number is error.\n");
getch();
}
改了,还是同样的错误


----------------解决方案--------------------------------------------------------
谢谢你了,感激不尽啊,我老是漏掉这些东西。对了顺便问下bioskey()这个是什么意思?
----------------解决方案--------------------------------------------------------
scanf("%d",&a);

----------------解决方案--------------------------------------------------------

函数名: bioskey
功 能: 直接使用BIOS服务的键盘接口
用 法: int bioskey(int cmd);
程序例:

#include <stdio.h>
#include <bios.h>
#include <ctype.h>

#define RIGHT 0x01
#define LEFT 0x02
#define CTRL 0x04
#define ALT 0x08

int main(void)
{
int key, modifiers;

/* function 1 returns 0 until a key is pressed */
while (bioskey(1) == 0);

/* function 0 returns the key that is waiting */
key = bioskey(0);

/* use function 2 to determine if shift keys were used */
modifiers = bioskey(2);
if (modifiers)
{
printf("[");
if (modifiers & RIGHT) printf("RIGHT");
if (modifiers & LEFT) printf("LEFT");
if (modifiers & CTRL) printf("CTRL");
if (modifiers & ALT) printf("ALT");
printf("]");
}
/* print out the character read */
if (isalnum(key & 0xFF))
printf("'%c'\n", key);
else
printf("%#02x\n", key);
return 0;
}


----------------解决方案--------------------------------------------------------
谢谢了,以后多向你学习
----------------解决方案--------------------------------------------------------
以下是引用限量版猪头在2007-4-24 12:28:01的发言:

函数名: bioskey
功 能: 直接使用BIOS服务的键盘接口
用 法: int bioskey(int cmd);
程序例:

#include <stdio.h>
#include <bios.h>
#include <ctype.h>

#define RIGHT 0x01
#define LEFT 0x02
#define CTRL 0x04
#define ALT 0x08

int main(void)
{
int key, modifiers;

/* function 1 returns 0 until a key is pressed */
while (bioskey(1) == 0);

/* function 0 returns the key that is waiting */
key = bioskey(0);

/* use function 2 to determine if shift keys were used */
modifiers = bioskey(2);
if (modifiers)
{
printf("[");
if (modifiers & RIGHT) printf("RIGHT");
if (modifiers & LEFT) printf("LEFT");
if (modifiers & CTRL) printf("CTRL");
if (modifiers & ALT) printf("ALT");
printf("]");
}
/* print out the character read */
if (isalnum(key & 0xFF))
printf("'%c'\n", key);
else
printf("%#02x\n", key);
return 0;
}

在编译#include <bios.h> 出现 No such a file or directory 的错误,是不是C-Free3.5中没有这一头文件啊?那怎么办呢?它具体用在什么地方啊?

在操作系统中不是已经启动了基本输入输出系统吗?为什么还要用到bios啊?


----------------解决方案--------------------------------------------------------
  相关解决方案