枚举 PROBLEM 1 生理周期

/**give one day that 3 physiological peak occur simultaneously */

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
    
#include < cstdlib >
#include
< iostream >

using namespace std;
/* *
*this program is a daily test
*problem set 1 : enumeration
* problem 1 : physiological cycle
*/
int main( int argc, char * argv[])
{
int p = 0 ;
int e = 0 ;
int i = 0 ;
int d = 0 ;
int k = 0 ;
while ( 1 )
{
printf(
" INPUT \n " );
scanf(
" %d%d%d%d " , & p, & e, & i, & d);
// you should simultaneously satisfy 3 conditions
for (k = d + 1 ;k < 21252 ;k ++ )
{
if ( 0 == (k - p) % 23 )
{
break ;
}
}
for (;k < 21252 ;k = k + 23 ) // notice k+23..not k+1
{
if ( 0 == (k - e) % 28 )
{
break ;
}
}
for (;k < 21252 ;k = k + 23 * 28 )
{
if ( 0 == (k - i) % 33 )
{
break ;
}
}
printf(
" the next physiological cycle is %d \n " ,k - d);
}
system(
" PAUSE " );
return EXIT_SUCCESS;
}

总结:

重新开始做acm题,发现编程已经相当生疏。

解决了dev-c++ 不能debug的问题

转载于:https://www.cnblogs.com/ggppwx/archive/2010/04/15/1712473.html

猜你喜欢

转载自blog.csdn.net/weixin_34258078/article/details/93871246
今日推荐