第8章例题--生理周期--2977

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

int main()
{
    int p,e,i,d;
	int num, j;

	num = 0 ;
	while(scanf("%d %d %d %d",&p,&e,&i,&d) && !( p == -1 && e == -1 && i == -1 && d == -1 ))
	{	
		num ++ ;
		for ( j = d + 1 ; j < 21252 ; j ++ )
			if( (j - p) % 23 == 0 ) break ;
		for( ; j < 21252 ; j = j + 23 )
			if( (j - e) % 28 == 0 ) break ;
		for( ; j < 21252 ; j = j + 23 * 28 )
			if( (j - i) % 33 == 0 ) break;
		printf("Case %d: the next triple peak occurs in %d days.\n", num , j - d );
	}
    
    return 1;    
}

你可能感兴趣的:(程序设计导引及在线实践)