[学习笔记]C++学习第8天
```# include <iostream>
# include <array>
// c++17
using namespace std;
int main()
{
int total{};
int values[]{2,3,5,7,11,13,17,19,23,29};
for (auto x:values)
total += x;
cout << "total = " << total << endl;
// n!
cout << "Enter a number named n, let's calculate n! ";
int n{};
cin >> n;
auto result{1LL};
if (n<2)
result =1;
else
while(n)
result *= n--;
cout << "n!= " << result << endl;
}
```
```
# include <iostream>
# include <array>
# include <cctype>
//c++17
using namespace std;
int main()
{
double temp{};
double total {};
int count{};
char reply{};
do{
cout << "Enter a temerature: ";
cin >> temp;
total += temp;
++count;
cout << "Do you want to enter another?(y/n): ";
cin >> reply;
}while(tolower(reply) == 'y');
cout << "The average temperature is " << total / count << endl;
}
```
加油加油呀 正在学习, 太水了一点,每天学习突出相关语言特性比较好!
页:
[1]