for循环练习题(1 ,判断任意一个数是91的多少倍 2,编写程序实现给定一个整数判断它从0到这个整数中间出现多少次9的次数)

2023-05-13,,

 1 //判断任意一个数是9的多少倍


#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("请输入任意一个数\n"); int c, a, b;
scanf_s("%d", &c);
printf("它对9的倍数是:\n");
if (c >=){ a = c / ; printf("%d\n", a);
}
else{
printf("0\n");
}
system("pause");
return ;
}


 //编写程序实现给定一个整数判断它从0到这个整数中间出现多少次9的次数

 #include <stdio.h>
#include <stdlib.h>
int main()
{ int i;
int start, end;
int l = ;
//temp的意义在于将i的值储存在temp中,用temp去模10余10,而i用于累加,二者不能重复
int temp;
printf("亲爱的用户您好,为了计算您要的结果,请您输入任意一个您想要的范围O(∩_∩)O\n");
scanf_s("%d %d", &start,&end);
printf("您要的结果如下:\n");
int count = ;
//for用来数数,一个数字一个数字过,while相当于计数器,计一共有多少个这样的数
for (i = start; i <= end; i++){ temp = i;
while (temp > ){
if (temp % == ){
count++;
}
temp = temp / ; }
}
printf("%d\n", count);
system("pause"); return ;
}
//测试发现大概计算范围到1~一千万左右,再往上写无法计算结果

for循环练习题(1 ,判断任意一个数是91的多少倍 2,编写程序实现给定一个整数判断它从0到这个整数中间出现多少次9的次数)的相关教程结束。

《for循环练习题(1 ,判断任意一个数是91的多少倍 2,编写程序实现给定一个整数判断它从0到这个整数中间出现多少次9的次数).doc》

下载本文的Word格式文档,以方便收藏与打印。