Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef __cplusplus
- #include <iostream>
- #include <iomanip>
- #include <array>
- #else
- #include <stdio.h>
- #endif
- int main() {
- #ifdef __cplusplus
- auto a = std::array {
- 10.67, 68.43, 56.55, 92.60, 90.65,
- };
- #else
- double a[] = {
- 10.67, 68.43, 56.55, 92.60, 90.65,
- };
- size_t const a_sz = sizeof(a) / sizeof(*a);
- #endif
- #ifdef __cplusplus
- std::cout << "array elements are:\n";
- std::cout << std::fixed
- << std::setprecision(2);
- for (auto d : a) {
- std::cout << std::setw(8) << d;
- }
- std::cout << std::endl;
- #else
- printf("array elements are:\n");
- for (size_t i = 0; i < a_sz; i++) {
- printf("%8.2f", a[i]);
- }
- putchar('\n');
- #endif
- return 0;
- }
Add Comment
Please, Sign In to add comment