1 / 11

第一題

第一題. #include &lt; stdio.h &gt; #include &lt; stdlib.h &gt; void myFunc (void); int main(void) { myFunc (); system(&quot;pause&quot;); return 0; } void myFunc (void) { printf (&quot;&quot;\\//\\//&quot;I want pass!&quot;\\//\\//&quot;<br>&quot;); }. 第二題. #include &lt; stdio.h &gt; #include &lt; stdlib.h &gt;

kamala
Download Presentation

第一題

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> #include <stdlib.h> void myFunc(void); int main(void) { myFunc(); system("pause"); return 0; } void myFunc(void) { printf("\"\\\\//\\\\//\"I want pass!\"\\\\//\\\\//\"\n"); }

  2. 第二題 • #include <stdio.h> • #include <stdlib.h> • int main(void) • { • intage,x; • printf("1.\n"); • if(age>=65); //多出了";" • printf("Age is greater than or equal to 65\n"); • else • printf("Age is less thawn 65\n"); • printf("2.\n"); • while(x<=100) //沒有{ • total +=x; • ++x; //沒有} • system("pause"); • return 0; • }

  3. 第三題 • #include <stdio.h> • #include <stdlib.h> • intmyFunc(intmyarray[]); • intarray_size; • int main() • { • intarray_count = 0; • int array[]={3,1,0,3,4,3,1,-3,-7,2,6,8,-9,-4}; • array_size = sizeof(array); • array_count = myFunc(array); • printf("array的元素數目 = %d\n",array_count); • system("pause"); • return 0; • } • intmyFunc(intmyarray[]){ • return array_size/sizeof(myarray); • }

  4. #include <stdio.h> • #include <stdlib.h> • intmyFunc(intmyarray[]); • intarray_size; • int main() • { • intarray_count = 0; • int array[]={3,1,0,3,4,3,1,-3,-7,2,6,8,-9,-4}; • array_size = sizeof(array); • array_count = myFunc(array); • printf("array_count = %d\n",array_count); • system("pause"); • return 0; • } • intmyFunc(intmyarray[]){ • int loop, count = 0; • for(loop=0;loop<(array_size/sizeof(myarray));loop++){ • if(myarray[loop]>0){ • count++; • } • } • return count; • }

  5. 第四題 • #include <stdio.h> • #include <stdlib.h> • int main(void) • { • unsigned intmyAns=65535; • //short只有2Byte的空間無法存放65536。請將short改成int • myAns++; • printf("myAns=%d\n",myAns); • system("pause"); • return 0; • }

  6. 第五題 • #include <stdio.h> • #include <stdlib.h> • int main() • { • for(int loop=20;loop>=-15;loop-=5) • { • printf("%d",loop); • if(loop>-15) • printf(","); • } • printf("\n"); • system("pause"); • return 0; • }

  7. 第六題 • #include <stdio.h> • #include <stdlib.h> • float myAns(intrn); • int main(void) • { • printf("myAns = %f\n",myAns(10)); • system("pause"); • return 0; • } • float myAns(intrn) • { • float ans=0,i=1; • int loop; • for(loop=1;loop<=rn;loop++) • { • ans=ans+1/i; • i++; • } • return ans; • }

  8. 第七題 • #include <stdio.h> • #include <stdlib.h> • void swap(int *x,int *y); • int main(void) • { • int x=100,y=200; • swap(&x,&y); • system("pause"); • return 0; • } • void swap(int *x,int *y) • { • inttmp; • tmp=*x; • *x=*y; • *y=tmp; • printf("x=%d\ny=%d\n",*x,*y); • }

  9. 第八題 • #include <stdio.h> • #include <stdlib.h> • int main(void) • { • unsigned short num,bin[16]={0},loop; • scanf("%d",&num); • for(loop=0;loop<16;loop++) • { • if(num & 0x01) • { • bin[15-loop]=1; • num >>=1; • }else{ • bin[15-loop]=0; • num >>=1; • } • } • for(loop=0;loop<16;loop++) • printf("%d",bin[loop]); • system("pause"); • return 0; • }

  10. 第九題 • #include <stdio.h> • #include <stdlib.h> • int main(void) • { • printf("The character is 'A'.\nDon't say goodbye.\n"); • system("pause"); • return 0; • }

  11. 第十題 • #include <stdio.h> • #include <stdlib.h> • int main(void) • { • float ans=95.0/3+25*785; • printf("95/3+25*785=%f\n",ans); • system("pause"); • return 0; • }

More Related