【隐身守候】 2020-06-02 00:22 采纳率: 100%
浏览 134
已采纳

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条回答 默认 最新

  • threenewbee 2020-06-02 09:39
    关注
    #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

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么