一些注意事项:_stprintf()这个函数要求挺苛刻的,他调用的变量必须初始化否则无法正常运行;
还有关于vs2022一些安全性必须说一说,如果不设置的很多正常代码其实也无法运行,安全性对于个人开发者和学者其实必要性不是很大,初学者建议关闭,关闭方法是在调试按钮上选择最后一项,在选择c/c+,在将警告视为错误设置为否,在点击c/c++小三角,在代码生成的安全检测中选择禁用安全检查;
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
int main() {
const float pi = 3.1415926;
int height, width;
height = 600, width = 800;
initgraph(width, height);
setbkcolor(RGB(255, 255, 255));
setlinestyle(PS_SOLID, 3);
float lineLength = 160, xend, yend, rotatespeeed = pi / 360;
int linenum = 0;
float angles[1000];
int score = 0;
int i;
BeginBatchDraw();
while (1) {
cleardevice();
setlinecolor(RGB(0, 0, 0));
line(0, height / 2, lineLength, height / 2);
for (i = 0; i < linenum; i++) {
angles[i] = angles[i] + rotatespeeed;
if