讨论串 /cpp_gcc@rextester_bot
4 条消息 · –已 C C++ vs Python#include <iostream> #include <cmath> using namespace std; double funk(double x); { return 1.0/(1+x*x); } int main(){ int a, b; double x, S; cout<<" chegaralarni kiriting : "; cin>>a>>b; S=0; x=a; double h=(b-a)/n; for(int i=1; i<=n; i++) { y=funk(x); x+=h; S+=y; } S*=h; cout<<S; return 0; }已 Errors: 1035285509/source.cpp:5:1: error: expected unqualified-id before ‘{’ token { ^ 1035285509/source.cpp: In function ‘int main()’: 1035285509/source.cpp:15:16: error: ‘n’ was not declared in this scope double h=(b-a)/n; ^ 1035285509/source.cpp:18:1: error: ‘y’ was not declared in this scope y=funk(x); ^ Tip: Mistake? Edit your message, I'll adjust my response.