#include <cstdlib>
#include <iostream>
#define SENTINEL 0
#define NUM_MONTHS 12
using namespace std;
int main(void)
{
int month,mem_sight,sightings;
cout<<"BALD EAGLE SIGHTINGS"<<endl;
for(month=1;month<=NUM_MONTHS;month++){
sightings=0;
cin>>mem_sight;
while (mem_sight != SENTINEL){
if(mem_sight>=0)
sightings += mem_sight;
else
cout<<"Warning, negative count ignored"<<mem_sight<<endl;
cin>>mem_sight;
}
cout<<"month : "<<month<<sightings;
}
system("PAUSE");
return EXIT_SUCCESS;
}
#include <iostream>
#define SENTINEL 0
#define NUM_MONTHS 12
using namespace std;
int main(void)
{
int month,mem_sight,sightings;
cout<<"BALD EAGLE SIGHTINGS"<<endl;
for(month=1;month<=NUM_MONTHS;month++){
sightings=0;
cin>>mem_sight;
while (mem_sight != SENTINEL){
if(mem_sight>=0)
sightings += mem_sight;
else
cout<<"Warning, negative count ignored"<<mem_sight<<endl;
cin>>mem_sight;
}
cout<<"month : "<<month<<sightings;
}
system("PAUSE");
return EXIT_SUCCESS;
}
Bahasa C++ run
Tidak ada komentar:
Posting Komentar