在屏幕上用“*”显示0--360度的余弦函数cos(x)曲线。不能使用数组。
此题目为C语言学生第一次熟悉环境用,不能用于考试。其中包含四处错误,请修正后提交,并检查提交结果。
参考源代码:
#include <stdio.h>
#include <math.h>
int main(void)
{
double y;
int x;
int m;
for (y = 1;y >= -1;y -= 0.1)
{
m = (int)acos(y)*10;
for (x = 1,x < m; x++)
{
printf(" ");
printf("*");
}
for(;x<62-m; x++)
{
printf(" ");
printf("*\n") ;’
}
}
}
错误提示:
--------------------Configuration: h - Win32 Debug--------------------
Compiling...
hf.c
C:\Program Files\Microsoft Visual Studio\MyProjects\h\hf.c(12) : error C2018: unknown character '0xa3'
C:\Program Files\Microsoft Visual Studio\MyProjects\h\hf.c(12) : error C2018: unknown character '0xac'
C:\Program Files\Microsoft Visual Studio\MyProjects\h\hf.c(12) : error C2146: syntax error : missing ';' before identifier 'x'
C:\Program Files\Microsoft Visual Studio\MyProjects\h\hf.c(12) : error C2059: syntax error : ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\h\hf.c(13) : error C2143: syntax error : missing ')' before '{'
C:\Program Files\Microsoft Visual Studio\MyProjects\h\hf.c(20) : error C2018: unknown character '0xa1'
C:\Program Files\Microsoft Visual Studio\MyProjects\h\hf.c(20) : error C2018: unknown character '0xaf'
Error executing cl.exe.
h.exe - 7 error(s), 0 warning(s)