VC++ (forstatement.cpp):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | //Chapter 1 - for statement #include <iostream> using namespace std; int main( void ) { int i = 0, j = 0, len = 0; const double PI = acos (-1.0), DEGREE = 180.0/PI; for (i=0;i<=180;i+=10) { len = ( int )( sin ( i/DEGREE )*30 ); for (j=0;j<len;j++) { cout << '*' ; } cout << " " << len << endl; } system ( "pause" ); return 0; } |
說明:
基本使用for迴圈印出sin波範例
沒有留言:
張貼留言