求答案
uj5u.com熱心網友回復:
運行結果,28年。僅供參考。#include <stdio.h>
int main(void)
{
int i, p, s;
for(i=1; i<40; i++)
{
p = 40 + i;
s = 6 + i;
if(p == 2*s)
{
printf("Years:\t%d\n", i);
break;
}
}
}
uj5u.com熱心網友回復:
#include <stdio.h>
int main(void)
{
int i = 0;
int father_age, son_age;
father_age = 40;
son_age = 6;
while (1) {
father_age = 40 + i;
son_age = 6 + i;
if (father_age / son_age == 2 && father_age % son_age == 0) {
printf("%d, %d\n", father_age, son_age);
break;
}
i++;
}
printf("%d\n", i);
#if 0
for(i=1; i<40; i++)
{
p = 40 +i;
s = 6 +i;
if(p == 2*s)
{
printf("Years:\t%d\n", i);
}
}
#endif
}
供參考~
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/225176.html
標籤:C語言
下一篇:C語言
