help me to programming c++ !! basic programming

来源:百度知道 编辑:UC知道 时间:2024/05/26 05:21:55
#include <iostream>
#include <string>
#include <cstdlib> // exit prototype
using namespace std;

void outputLine(long);

int main()
{
// Giving up on reading from hard drive. Make dates an array.
// If you can make reading from a file work, extra credit
// (a little).
long DataArray[] =
{
19531029L,
20081104L,
19770615L,
19300723L,
19631122L,
19410501L,
19700820L,
20051031L,
19983423L,
22200101L,
19609599L
};

// display each record in the "file" -- array, here.
int i = 0;
while (i < 11)
{
outputLine(DataArray[i]);
i++;
}

return 0; //

} // end main

// Test and display single record from array

void outputLine(long bdate) {

// This array needs to be local to the function.
// Or global

第一个// Stuff deleted.处改为:
"Marcy",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"

第二个// Stuff deleted.处改为:
if (month < 1)
Valid = false;
else if (month > 12)
Valid = false;
if (day < 1)
Valid = false;
else
{
int t=((year%100!=0 && year%4==0) || year%400==0)? 1:0
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: if(day>31) Valid=false;break;
case 4:
case 6:
case 9:
case 11: if(day>30) Valid=false;break;
case 2: if(day>28+t) Valid=false;break;
}
}

// One statement deleted here. Involves an array 处改为:
cout << monthName[month-1] << " " << day &