Click here to load reader

* 分解出百位 *

  • View
    137

  • Download
    10

Embed Size (px)

DESCRIPTION

题目:打印出所有的 “ 水仙花数 ” ,所谓 “ 水仙花数 ” 是指一个三位数,其各位数字立方和等于该数本身。例如: 153 是一个 “ 水仙花数 ” ,因为 153=1 的三次方+ 5 的三次方+ 3 的三次方。 程序分析:利用 for 循环控制 100-999 个数,每个数分解出个位,十位,百位。. - PowerPoint PPT Presentation

Text of * 分解出百位 *

  • 153153=153for100-999

  • main() { int i,j,k,n; printf("'water flower'number is:"); for(n=100;n
  • 101max2max
  • #include stdio.hmain(){int max, next, n; scanf(%d,&next); max=next; for (n=2;nmax) max=next; }printf(max=%d\n, max);}/* *//* *//* */

  • 9999123 45 5678 34 9999 67 2345656789999#include stdio.hmain(){int max, next, n; scanf(%d,&next); max=next; for ( ; next!=9999; scanf(%d,&next) ) { if (next>max) max=next; } if (max!=9999) printf(max=%d\n, max);}/* */

  • #include void main(){ int cc1,cc2,cc3,cc4,cc5; int A,B,C,D,E; int g; for(A=1; A
  • a,b,cx,y,zaxcx,z

  • main() { char i,j,k; for(i='x';i
  • mn GCD(A, B)=GCD(B, A%B)A%B==0BGCD1218=GCD1812 =GCD126 =GCD6012186

  • main() { int a,b,temp; printf("please input two numbers:\n"); scanf("%d,%d",&a,&b); while(b!=0) /*b0*/ { temp=a%b; a=b; b=temp; } printf("gongyueshu:%d\n",a); }

  • 1flagflag=1flag=0212n-1n/2

  • #include stdio.hmain(){ int n, i,flag=1; printf(); scanf(%d,&n); for (i=2;i
  • 10 T N=T N-1-T N-1 / 2+1T N-1=2*T N + 2T10=1T NN=981

  • main() { int day,x1,x2; day=9; x2=1; while(day>0) {x1=(x2+1)*2; x2=x1; day--; } printf("the total is %d\n",x1); }

    /*212*/

  • main() { int day,x=1; for(day=9;day
  • 5 num1!=0nk++num2=num2*10+nnum1

  • main(){long num1, num2=0 int k=0, n;scanf(%ld, &num1);while (num1!=0) {k++; n=num1%10; num2=num2*10+n; num1=num1/10;}printf(num1%ld\n, k);printf(num2=%d\n, num2);} num1num2knum1nnum1/**/

  • 10016810100268

  • #include "math.h" main() { long int i,x,y,z; for (i=1;i
  • 5,10

  • main() {int a,i,aa[4],t; scanf("%d",&a); aa[0]=a%10; aa[1]=a%100/10; aa[2]=a%1000/100; aa[3]=a/1000; for(i=0;i
  • 31,1,2,3,5,8,13,21....

  • main() { long f1,f2; int i; f1=f2=1; for(i=1;i
  • 10 1. 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10105 1

  • main() {int i, j, a[10][10]; printf("\n"); for(i=0;i
  • 1n-1 2 n-1 3

  • #include stdio.hmain(){ int a[10], i, j, temp; for (i=0; i
  • N123NK1MM1M a[ i ]=1 a[ i ]=0 sum=0sum==0 sum0

  • main(){ int j, k=0,sum=0; int a[21]; for (i=1;i

Search related