c语言初学者,请各位大佬帮帮忙!!!谢谢!!!

目前世界上人口为60亿,如果以每年1.4%的速度增长,n(n为正整数)年后世界人口达到80亿,求n。
Private Sub command1_Click()
Dim p As Single
Dim r As Single
Dim n As Integer
FontSize = 14: FontBold = True
p = 60
r = 0.014
n = 0
Do
n = n + 1

       Loop Until p >= 80
       Print n

End Sub

求三位数中,个位数字与十位数字之和除以10所得的余数是百位数字,且百位数字是偶数的数的个数。
Private Sub Form_click()
Dim s As Integer
Dim x As Integer
Dim a As Integer
Dim b As Integer
Dim c As Integer
s = 0
x = 100
Do While x <= 999
a = Int(x / 100)
b = Int(x / 10) - a * 10
c = x - a * 100 - b * 10
If Then s = s + 1
x = x + 1
Loop
Print s
End Sub

1个回答

#include <stdio.h>
int main()
{
int n = 0;
float pop = 60.0f;
while (pop < 80.0f)
{
n++;
pop = pop * 1.014;
}
printf("%d", n);
}

21

#include <stdio.h>

int f(int n)
{
    int a = n % 10;
    int b = (n / 10) % 10;
    int c = n / 100;
    /* return (a + b) % 10 == c && 
        ((a % 2 == 1 ? a : 0) + (b % 2 == 1 ? b : 0) + (b % 2 == 1 ? b : 0) == c);
    */
    return (a + b) % 10 == c && c % 2 == 0;
}

int main()
{
    int sum = 0;
    for (int i = 111; i <= 999; i++)
    {
        if (f(i)) { sum += i; printf("%d ", i); }
    }
    printf("\n%d", sum);
    return 0;
}

202 211 220 239 248 257 266 275 284 293 404 413 422 431 440 459 468 477 486 495 606 615 624 633 642 651 660 679 688 697 808 817 826 835 844 853 862 871 880 899
21980

问题解决的话,请点下采纳

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问