1 / 5

//4.3 #include<stdio.h> void main() { int i,j,m; printf(" *"); for(i=1;i<=9;i++)

//4.3 #include&lt;stdio.h&gt; void main() { int i,j,m; printf(&quot; *&quot;); for(i=1;i&lt;=9;i++) printf(&quot;%4d&quot;,i); printf(&quot;<br>&quot;); for(i=1;i&lt;=9;i++) { printf(&quot;%4d&quot;,i); for(j=1;j&lt;=i;j++) { m=i*j; printf(&quot;%4d&quot;,m); } printf(&quot;<br>&quot;); } }. //4.5 #include&lt;stdio.h&gt;

Download Presentation

//4.3 #include&lt;stdio.h&gt; void main() { int i,j,m; printf(&quot; *&quot;); for(i=1;i&lt;=9;i++)

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. //4.3 #include<stdio.h> void main() { int i,j,m; printf(" *"); for(i=1;i<=9;i++) printf("%4d",i); printf("\n"); for(i=1;i<=9;i++) { printf("%4d",i); for(j=1;j<=i;j++) { m=i*j; printf("%4d",m); } printf("\n"); } }

  2. //4.5 #include<stdio.h> void main() { int i,n,p; scanf("%d",&n); p=1; //1 for(i=1;i<=n;i++) p*=i; //2 printf("%d,%d\n",n,p); }

  3. 4.6 #include<stdio.h> void main() { int num; int long sum1=0,sum2=1; scanf("%d",&num); // 1 do { sum1+=num; //2 sum2*=num; }while(--num>0); //3 printf("%ld,%ld",sum2,sum1); }

  4. 4.12 //求1~100以内所有的完数 #include<stdio.h> void main() { int i,j,sum; for(i=1;i<100;i++) { sum=0; for(j=1;j<i;j++) if(i%j==0) sum+=j; if(sum==i) printf("%d是一个完数\n",i); } }

  5. //换零钱问题 #include<stdio.h> void main() { int a,b,c,sum=0; //a,b,c分别表示1、2、5分钱的个数 for(a=0;a<=100;a++) for(b=0;b<=50;b++) for(c=0;c<=20;c++) if(a*1+b*2+c*5==100) { sum+=1; printf("1分钱有%d个,2分钱%d个,5分钱有%d个\n",a,b,c); } printf("一共有%d种分法\n",sum); }

More Related