c++3 - 第第第 第第 第第第第 第 第 C++...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 第第第 第第 第第第第 第 第 C++ 语语语语语语 2 C++ 语语语语语语 语语语语 语语 第第第第第第 第第第第第第第第 第第第第第第第第 第第第第 第第第第第第第第第 第第第第 C++ 第第第第 3 C++ 语语语语语语 语语语语 语语 第第第第第 第第第第第第第第第第第第第第第第第第第 第第第第第第第第第 语语语语语 语语语语语语语语语语 { 语语语语 } 语语语语语语语语语语语语语语语语语语语语语语语 语 语语语语语语语 void 4 C++ 语语语语语语 语语语语 语语 第第第第第 第第第第第 <type 1 > name 1 , <type 2 > name 2 , ..., <type n > name n 第第第第第第 – 语 return 语语语语语语语语 return – 语语语语语语语语 void 语语语语语语语 return 语语语 5 C++ 语语语语语语 语语语语 语语 第第第第第 第第第第第第第第第第第 – 语语语语语语语语语语语语语语语语语语语语语语语语语语语语 语语语语语 语语语语语语语语语语语语语语语语语 ; 第第第第 语语语语语语语语语 第第第第 – 语语语语语语语语语语语语语语语语语语 – 语语语语 – 语语语语语语语语语语语语 6 C++ 语语语语语语 语语语语 语语 第 3-1 第第第第第 x 第 n 第第第第第 #include <iostream> using namespace std; double power(double x, int n); int main() { cout<<"5 to the power 2 is " << power (5,2)<<endl; } double power(double x, int n) { double val=1.0; while (n--) val=val*x; return(val); } 7 C++ 语语语语语语 语语语语 语语 第第第第第 5 to the power 2 is 25 第 3-1 第第第第第 x 第 n 第第第第第 8 C++ 语语语语语语 语语语语 语语 第 3-2 第第第第 第第第 第第第第 8 第第第第第第第第第第第第第第第第第第 第第第 1101 2 =1(2 3 )+1(2 2 )+0(2 1 )+1(2 )=13 10 第第第第第第第 1101 第第第第第 13 #include <iostream> using namespace std; double power (double x, int n); int main() { int i; int value = 0; char ch; cout << "Enter an 8 bit binary number "; for (i = 7; i >= 0; i--) { cin >> ch; if (ch == '1') value += int( power (2,i)); } cout <<"Decimal value is "<<value<<endl; } double power (double x, int n) { double val = 1.0; while (n--) val *= x; return(val); } 第第第第第 Enter an 8 bit binary number 01101001 Decimal value is 105 9 10 C++ 语语语语语语 语语语语 语语 第 3-3 第第第第第 π 第第 第第 arctan 第第第第第第第第第第第 第第第第第第第第第第第第 10-15 第第第 π 第 x 第第 double 第第 - = 239 1 arctan 4 5 1 arctan 16 π +- +- = 7 5 3 ) arctan( 7 5 3 x x x x x #include<iostream> using namespace std; int main() { double a,b; double arctan (double x);// 第第第第第第 a=16.0* arctan (1/5.0); b=4.0* arctan (1/239.0); // 第第第第第第第第第第第第第第 // 第第第第第 1/5 第 1/239 第第第第第第 0 cout<<"PI="<<a-b<<endl; } 11 double arctan(double x)...
View Full Document

This note was uploaded on 10/26/2010 for the course CS 071122 taught by Professor Xuxiaohua during the Fall '07 term at Tsinghua University.

Page1 / 67

c++3 - 第第第 第第 第第第第 第 第 C++...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online