标签:names cpp char div return exp ios pac turn
#include <iostream> #include <array> #include <string> const int Seasons = 4; const char * Snames[4] = { "Spring", "Summer", "Fall", "Winter" }; void fill(double pa[]); void show(double da[]); int main() { double expenses[4]; fill(expenses); show(expenses); return 0; } void fill(double pa[]) { using namespace std; for (int i = 0; i < Seasons; i++) { cout << "Enter " << Snames[i] << " expenses: "; cin >> pa[i]; } } void show(double da[]) { using namespace std; double total = 0.0; for (int i = 0; i < Seasons; i++) { cout << Snames[i] << ": $" << da[i] << endl; total += da[i]; } cout << "Total Expenses: $" << total << endl; }
标签:names cpp char div return exp ios pac turn
原文地址:https://www.cnblogs.com/ranwuer/p/9768083.html