猿问

为什么别人机器上能完美运行的程序在我的机器上不行?都是什么错误啊?

#include <graphics.h>
#include <conio.h>
void main()
{int x,y; 
initgraph(600,600);
for(x=25,y=25;x<=475,y<=475;x+=20,y+=20)
{

setcolor(GREEN);
setfillstyle(YELLOW);
fillellipse(x,y,25,25);
Sleep(500);
cleardevice();
for (int x=475,y=475;x<=25,y<=25;x-=20,y-=20)
{

setcolor(GREEN);
setfillstyle(YELLOW);
fillellipse(x,y,25,25);
Sleep(500);
cleardevice();

}
}

然后一堆错误.
--------------------配置: mingw5 - CUI Debug, 编译器类型: MinGW--------------------

检查文件依赖性...
正在编译 G:\程序语言cpp\Debug\圆.cpp...
[Error] G:\程序语言cpp\Debug\圆.cpp:4: error: `main' must return `int'
[Warning] G:\程序语言cpp\Debug\圆.cpp:5: warning: converting to non-pointer type `int' from NULL
[Error] G:\程序语言cpp\Debug\圆.cpp:6: error: stray '\163' in program
[Error] G:\程序语言cpp\Debug\圆.cpp:6: error: stray '\187' in program
[Error] G:\程序语言cpp\Debug\圆.cpp:6: error: expected `;' before "x"
[Error] G:\程序语言cpp\Debug\圆.cpp:6: error: expected `;' before ')' token
[Warning] G:\程序语言cpp\Debug\圆.cpp:25:2: warning: no newline at end of file
[Error] G:\程序语言cpp\Debug\圆.cpp:25: error: expected `}' at end of input

构建中止 圆: 6 个错误, 2 个警告

皈依舞
浏览 200回答 2
2回答

守着星空守着你

1.[Error] G:\程序语言cpp\Debug\圆.cpp:4: error: `main' must return `int'我学的C++的main()函数都是返回int值得,int main(),你改成这样最后return 0就可以了2.[Error] G:\程序语言cpp\Debug\圆.cpp:6: error: stray '\163' in program[Error] G:\程序语言cpp\Debug\圆.cpp:6: error: stray '\187' in program这个是出现中文字符了,for(x=25,y=25;x<=475,y<=475;x+=20,y+=20)中的分号是中文符号,改成英文的就可以了3.[Error] G:\程序语言cpp\Debug\圆.cpp:25: error: expected `}' at end of input你程序的最后少了个"}"

牧羊人nacy

既然是学习,就必须学会看提示,这些提示都是有意义的,不是无聊的乱码
随时随地看视频慕课网APP
我要回答