clwn.net
当前位置:首页 >> C语言 输入两个正整数m和n(m>=1,n<10000),输出m到n之间的所有水仙花数。... >>

C语言 输入两个正整数m和n(m>=1,n<10000),输出m到n之间的所有水仙花数。...

你for语句没有加{},只执行了gw=i%10 这一句话.还有,水仙花数只是三位数吧.

#include "stdio.h" int fib(int n) { if (n==1||n==2)return 1; else return fib(n-1)+fib(n-2); } void main() { int i,n,m,t; printf("请输入m n:"); scanf("%d%d",&m,&n); for(i=1;;i++) { t=fib(i); if(t>=m&&t<=n) printf("%d ",t); else if(t>n)break; } printf("\n"); }

#include "stdio.h"int is(int number){ int temp = number,sum = 0; if(temp<1)return 0; while(temp>0) { sum += (temp%10)*(temp%10)*(temp%10); temp /= 10; } if(sum == number) return 1; return 0;}void main(){ int m,n,temp; printf("Please input m,

#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h> int is(int number){ int d1=number/1%10; int d2=number/10%10; int d3=number/100%10; if(number==d1*d1*d1+d2*d2*d2+d3*d3*d3) { return 1; } else { return 0; }} int main(){

#include int shuixianhua(int m) { int s=0,flag=0,a,b,c; a=m/100;//百位 c=m%10;//个位 b=m/10%10;//十位 s+=a*a*a+b*b*b+c*c*c ; if(s==m) { flag=1; //printf("a=%d, b=%d, c=%d, s=%d\n", a, b, c, s); } return(flag); } main() { int start = 0, end = 0;

#include<stdio.h> int main(void) { int m = 0; int n = 0; int i = 0; int sum = 0; printf("Enter two numbers:"); scanf("%d %d",&m,&n); if(m < n) { for(i = m; i <= n; i++) { sum += i; } printf("Sum is %d",sum); } else { printf("Enter Error"); } return 0; }

#include "stdio.h"main(){ int m,n,i; long int sum=1,sum1=1,sum2=1,t; printf("请输入m&gt;n\n"); scanf("%d",&amp;m); scanf("%d",&amp;n); while(m&lt;n) { clrscr(); printf("请重新输入m,n\n"); scanf("%d",&amp;m); scanf("%d",

#include<stdio.h>int main(int argc, char* argv[]){ int i,m,n; int fib(int n); scanf("%d%d",&m,&n); while(m>=1&&n<=10000&&m<=n) { for(i=m;i<=n;i++) printf("%d ",fib(i)); printf("\n"); scanf("%d%d",&m,&n); } return 0;}int fib(int n){ if(n==1) return 1; if(n==2) return 1; else return fib(n-1)+fib(n-2);}

m mmm,

//---------------------------------------------------------------------------#include int factorsum(int n) { int i,sum=0; for (i=1; i return sum; } int main(void) { int n,m; printf("m="); scanf("%d",&m); printf("n="); scanf("%d",&n); while (m { if (factorsum(m)==m)

相关文档
网站首页 | 网站地图
All rights reserved Powered by www.clwn.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com