一開始上課時先做瘋狂程設的金牌
第一題:[進階題:計算一列整數的總和]
程式碼:
#include <stdio.h>
int main()
{
int ans=0;
while(1){
printf("Enter an integer ( 999 to end ): \n");
int now;
scanf("%d", &now);
if(now==999)break;
ans+= now;
}
printf("The total is: %d",ans);
}
程式碼:
#include <stdio.h>
int main()
{
printf("Enter two integers: \n");
int a,b;
scanf("%d %d",&a, &b);
int ans=1;
for(int i=1;i<a;i++)
{
if(a%i==0 && b%i==0)
{
ans=i;
}
}
printf("The greatest common divisor of %d and %d is %d\n",a,b,ans);
}
先運用小畫家畫出左中右3個小人的圖案,接著利用ppt去背,再來用sketch寫程式碼,把3個圖片丟到sketch裡,就可以用鍵盤上的左右鍵來控制小人,看起來像小人在左右動的感覺,很厲害的啦



沒有留言:
張貼留言