1 #include <string> 2 #include <iostream> 3 //用于计算,计算的性能高于vector与array 4 #include <valarray> 5 #include <algorithm> 6 using namespace std; 7 8 9 void main() 10 { 11 const double PI = 3.1415926; 12 valarray<double> val(9); 13 for (int i = 0; i < 9; i++) 14 { 15 val[i] = PI * i*i; 16 cout << val[i] << endl; 17 18 } 19 20 valarray<double> valx(9); 21 for (int i = 0; i < 9; i++) 22 { 23 valx[i] = cos(i*PI / 3); 24 cout << valx[i] << endl; 25 } 26 27 //拥有数组所有的功能 28 valarray<char *>my; 29 cin.get(); 30 }
原文地址:https://www.cnblogs.com/xiaochi/p/8629686.html
时间: 2024-10-13 11:35:27