1 / 3

#include<stdio.h> void main() { int i,j,temp,k; for(i=1;i<=1000;i++) { temp=0;

#include<stdio.h> void main() { int i,j,temp,k; for(i=1;i<=1000;i++) { temp=0; for(j=1;j<i;j++) if(i%j==0) temp+=j; if(i==temp) { printf("%d ",i); // 此数为完数 printf("its factor are "); for(k=1;k<i;k++) // 再回过头来找其因子 if(i%k==0)

Download Presentation

#include<stdio.h> void main() { int i,j,temp,k; for(i=1;i<=1000;i++) { temp=0;

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. #include<stdio.h> void main() { int i,j,temp,k; for(i=1;i<=1000;i++) { temp=0; for(j=1;j<i;j++) if(i%j==0) temp+=j; if(i==temp) { printf("%d ",i); //此数为完数 printf("its factor are "); for(k=1;k<i;k++) //再回过头来找其因子 if(i%k==0) printf("%d " ,k); printf("\n"); } } } 谭浩强教材P123 6.7 求1000以内所有的完数

  2. //谭版教材P129 6.8 求分数序列2/1,3/2,5/3,8/5…前20项之和 #include<stdio.h> void main() { int i,a=2,b=1,t; float c=2.0; for(i=1;i<20;i++) { t=a; a=a+b; b=t; c+=(float)a/b; } printf("%f ",c); }

  3. #include<stdio.h> void main() { int i,j,k; for(i=1;i<=4;i++) //上面4行 { for(j=1;j<=4-i;j++) //空格 printf(" "); for(k=1;k<=2*i-1;k++) //* printf("*"); printf("\n"); } for(i=1;i<=3;i++)//下面3行 { for(j=1;j<=i;j++) //空格 printf(" "); for(k=1;k<=7-2*i;k++) //* printf("*"); printf("\n"); } } //谭版教材P130 6.14 编程输出以下图形 * * * * * * * * * * * * * * * * * * * * * * * * *

More Related