设计程序,输出100到200之间能被3或5整除的数

如题所述

#include <stdio.h>

int main()
{
    int i;
    for (i = 100; i <= 200; ++i)
    {
        if ((i % 3 == 0) || (i % 5 == 0))
        {
            printf("%d ", i);
        }
    }
    return 0;
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-05-22
for循环判断,a=(100+i)/3 if余0 print a i=1 i++ 步数 100
同理/5。我写的比较乱,就这个思想。
相似回答