您的位置:首页 > 其它

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

2011-12-15 15:10 169 查看
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <list>

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: