下列中不正确的预编译命令是
A. c语言编写钟表的问题
#include<graphics.h>
#include<math.h>
#include<dos.h>
#define PI 3.1415926
#define x0 320 /*定义钟表中心坐标*/
#define y0 240
void DrawClock(int x,int y,int color) /*画表盘*/
{ int r=150; /*表盘的半径*/
float th;
setcolor(color);
circle(x,y,r);
circle(x,y,2);
}
void DrawHand(int x,int y,float th,int l,int color)
{
int x1,y1;
x1=x l*sin(th);
y1=y-l*cos(th);
setcolor(color);
line(x,y,x1,y1);
}
void main()
{int gdriver=DETECT,gmode;
struct time curtime;
float th_hour,th_min,th_sec;
initgraph(&gdriver,&gmode,"");
setbkcolor(0);
while(! kbhit())
{
DrawClock(x0,y0,14);
gettime(&curtime); /*得到当前系统时间*/
gotoxy(35,20); /*定位输出位置*/
if((float)curtime.ti_hour<=12) /*午前的处理*/
{printf("AM ");
if((float)curtime.ti_hour<10) printf("0"); /*十点之前在小时数前加零*/
printf("%.0f:",(float)curtime.ti_hour);
}
else /*午后的处理*/
{printf("PM ");
if((float)curtime.ti_hour-12<10) printf("0");
printf("%.0f:",(float)curtime.ti_hour-12);
}
if((float)curtime.ti_min<10) printf("0");
printf("%.0f:",(float)curtime.ti_min);
if((float)curtime.ti_sec<10) printf("0");
printf("%.0f",(float)curtime.ti_sec);
/*以下三行计算表针转动角度,以竖直向上为起点,顺时针为正*/
th_sec=(float)curtime.ti_sec*0.1047197551; /*2π/60=0.1047197551*/
th_min=(float)curtime.ti_min*0.1047197551 th_sec/60.0;
th_hour=(float)curtime.ti_hour*0.523598775 th_min/12.0; /* 2π/12=0.5235987755 */
DrawHand(x0,y0,th_hour,70,2); /*画时针*/
DrawHand(x0,y0,th_min,110,3); /*分针*/
DrawHand(x0,y0,th_sec,140,12); /*秒针*/
sleep(1); /*延时一秒后刷新*/
cleardevice();
}
closegraph();
}
能正常运行,我测试过
来自网络转载
B. 一道C语言选择题,求答案。
答案应该是答滚选C
因为C语言规则规定:标准库函数不允许用户磨指进行重新定义,只能进行引用,调用前需使用预编译命令进瞎举配行预编译;
C. c语言基础知识题
单选
4、C 7、B 9、D 11、C 12、A
多选
2、ABD 4、BD 14、ABD 15、BCD
判断
1、A 2、B 3、B 4、B 5、A
6、B 7、B 8、B 9、A 10、B
D. c语言中#include <stdio.h>是什么意思
包含标准头文件stdio.h。
1、#include 是C语言预编译命令之一。
include并不属于C语言关键字。以#开头的#include是预编译命令,即不是在运行过程中生效,而是在编译的时候就会生效。
include的效果为,在编译时把被包含的文件中的内容,放到被编译的c文件对应位置。
2、stdio.h是C语言库文件的头文件之一,包含了常用的标准输入输出。
比如printf,scanf等语句都是在stdio.h中的。
3、在源文件中包含了stdio.h 就等于声明了stdio.h中的所有函数,并使该文件中的所有宏定义在源文件中可用。
即使用printf,scanf等语句不会引起警告, 同时可以使用诸如NULL一类的宏定义。