• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
TianXiCoding
博客园    首页    新随笔    联系   管理    订阅  订阅
c语言—找出1000以内21的倍数的数字有哪些

for循环: 

#include <stdio.h>
int main()
{
	int i;
	for ( i = 0; i <=1000; i++)
	{
		if (i%21==0)
		{
			printf("%d,",i);
		}
	}
	return 0;
} 

 while循环:

#include <stdio.h>
int main()
{
	 int a = 1;
	 while (a <= 1000)
	 {
		 if (a % 21 == 0) {
			 printf("%d ", a);
		 }
		 a++;
	 }
	return 0;
} 

posted on 2023-03-28 19:09  天喜Studio  阅读(61)  评论(0)    收藏  举报  来源
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3