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

求整数[2335,4321]之间即不能被3整除,又不能被5整除的奇数的个数。(530)
Private Sub Command1_Click()
Dim i As Integer, n As Integer
n = 0
For i = 2335 To 4321 Step 2
If Then
n = n + 1
End If
Next i
Print n
End Sub

设某四位数的各位数字的平方和等于100,共有多少个这种四位数?(49)
Private Sub Form_Click()
Dim a, b, c, d, i, count As Integer
count = 0
i = 1111
FontSize = 14: FontBold = True
Print: Print: Print
Do Until i > 9999
a = i \ 1000
b = (i Mod 1000) \ 100
c =

d = i Mod 10
If 100 = a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 Then count = count + 1
i = i + 1
Loop
Print count
End Sub

1个回答

#include <stdio.h> 
int main()
{
    int n = 0;
    for (int i = 2335; i <= 4321; i++)
    {
        if (i % 3 != 0 && i % 5 != 0 && i % 2 == 1)
            n++;
    }
    printf("%d", n);
}

530

#include <stdio.h>

int f(int n)
{
    int sum = 0;
    while (n > 0)
    {
        sum += (n % 10) * (n % 10);
        n /= 10;
    }
    return sum;
}

int main()
{
    int n = 0;
    for (int i = 1111; i <= 9999; i++)
    {
        if (f(i) == 100)
        {
            n++;
            printf("%d ", i);
        }
    }
    printf("\n%d", n);
    return 0;
}

1177 1339 1393 1557 1575 1717 1755 1771 1933 2448 2484 2844 3139 3193 3319 3391 3913 3931 4248 4284 4428 4482 4824 4842 5157 5175 5517 5555 5571 5715 5751 6008 6080 6800 7117 7155 7171 7515 7551 7711 8006 8060 8244 8424 8442 8600 9133 9313 9331
49

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

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