File tree Expand file tree Collapse file tree 3 files changed +41
-8
lines changed Expand file tree Collapse file tree 3 files changed +41
-8
lines changed Original file line number Diff line number Diff line change @@ -5,14 +5,7 @@ int main()
5
5
{
6
6
std::array<float , 3 > data;
7
7
std::cout << " Please input three times running record: " << std::endl;
8
-
9
- std::cin >> data[0 ];
10
- std::cin >> data[1 ];
11
- std::cin >> data[2 ];
12
-
13
- // data.at(0) = firstTime;
14
- // data.at(1) = secondTime;
15
- // data.at(2) = thirdTime;
8
+ std::cin >> data[0 ] >> data[1 ] >> data[2 ];
16
9
17
10
int times = data.size ();
18
11
float average = (data[0 ] + data[1 ] + data[2 ]) / times;
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ int main ()
4
+ {
5
+ using namespace std ;
6
+ int x;
7
+
8
+ cout << " The expression x = 100 has the value " ;
9
+ cout << (x = 100 ) << endl;
10
+ cout << " Now x = " << x << endl;
11
+ cout << " The expression x < 3 has the value " ;
12
+ cout << (x < 3 ) << endl;
13
+ cout << " The expression x > 3 has the value " ;
14
+ cout << (x > 3 ) << endl;
15
+ cout.setf (ios_base::boolalpha);
16
+ cout << " The expression x < 3 has the value " ;
17
+ cout << (x < 3 ) << endl;
18
+ cout << " The expresion x > 3 has the value " ;
19
+ cout << (x > 3 ) << endl;
20
+
21
+ return 0 ;
22
+ }
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ const int ArSize = 16 ;
4
+
5
+ int main ()
6
+ {
7
+ long long factorials[ArSize];
8
+ factorials[1 ] = factorials[0 ] = 1LL ;
9
+ for (int i = 2 ; i < ArSize; i++)
10
+ {
11
+ factorials[i] = i * factorials[i-1 ];
12
+ }
13
+ for (int i = 0 ; i < ArSize; i++)
14
+ {
15
+ std::cout << i << " ! = " << factorials[i] << std::endl;
16
+ }
17
+ return 0 ;
18
+ }
You can’t perform that action at this time.
0 commit comments