回覆列表
  • 1 # 影片好笑

    for迴圈#include<stdio.h>main(){int i,s=0;for(i=1;i<=100;i++)s+=i; printf("s=%d",s);}方法一定義求和函式#include<stdio.h>int add(int,int);main(){int i,y;for(y=0,i=1;i<=100;i++)y=add(y,i);printf("%d",y);}int add(int a,int b){int s=0;s=a+b;return s;}方法二do while求和#include<stdio.h>main(){int i=1,s=0;do{s=s+i;i++;}while(i<=100);printf("s=%d",s);} 方法三while#include<stdio.h>main(){int i=1,s=0;while(i<=100){s+=i;i++;} printf("s=%d",s);}方法四遞迴求和#include<stdio.h>int fun(int n){if(n==1)return 1;return n+fun(n-1);}main(){printf("%d",fun(100));}

  • 中秋節和大豐收的關聯?
  • 形容“俗”的成語有哪些?