函数名字与返回值类型在语义上不可冲突

函数名字与返回值类型在语义上不可冲突。

违反这条规则的典型代表是 C 标准库函数 getchar。

 

 1 #include <iostream>
 2 #include <stdlib.h>
 3 #include <math.h>
 4 #define PI 3.1415926535
 5 
 6 //main()函数的定义
 7 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 8 using namespace std;
 9 int main(int argc, char** argv) {
10     int i;
11     double d=180/PI;
12 
13     cout<<"X\tASIN(X)\t\tACOS(X)"<<endl;
14     cout<<"---------------------------------------"<<endl;
15     for (double x=0;x<=1.0+0.05;x=x+0.1) {
16         cout<<x<<"\t";
17         cout<<int(asin(x)*d)<<"\t\t";
18         cout<<int(acos(x)*d)<<endl;
19    }
20 }

 

posted @ 2018-08-03 13:09  borter  阅读(131)  评论(0编辑  收藏  举报