If a small cow, from birth to the fourth year, every year, one cow, according to this law, how many cows in the nth year? As follows:
#include #include #include
Int main (int Argc, char * argv []) {Vector cow_count; // Store intry = 0 of the annual born cow; // How many years Double SUM_TEMP = 0; // Temporary variable Cow_count.push_back (1); // Put the first cow into vector (cow_count), calculated, not which year. Cout << "Please enter the age of the first cow:" << Endl; cin >> Year; for (int = 1; ix <= year; ix ) {if (ix <4) // Less than four o'clock no cow born COW_COUNT.PUSH_BACK (0); if (ix> = 4 && ix <7) // The number of days is greater than four less than 7 pm Every year is born one {cow_count.push_back (1);} else {IF IX> = 7) {SUM_TEMP = 0; for (int JX = 0; JX <= IX - 4; JX ) // The number of birth cows is a four-year number of cows. {SUM_TEMP = SUM_TEMP COW_COUNT [JX];} COW_COUNT.PUSH_BACK (SUM_TEMP);}}}}}}}}}}}}}}}}}}}}}}}}}} OFSTREAM FILE ("D: //cow.txt"); for (int kx = 1; kx <= year; kx ) { SUM_TEMP = 0; for (int LX = 0; lx <= kx; lx ) {SUM_TEMP = SUM_TEMP COW_COUNT [LX];} // Output to Number Number, Number N Number of cows, live N-year cow number File << "to" << kx << "Year Care Number:" << Sum_Temp << "|"; file << "" << KX << "birth cattle Number: "<< cow_count [kx] <<" || "; file <<" Live "<< kx <<" Year Cattle Number: "<< Cow_count [Year - KX] << Endl;} Return 0 }