2013/12/23作業
#include <stdio.h> #include <stdlib.h> int main(void) { int a,b,c,d,i,h; while ( 1 ){ printf("請輸入數值:"); scanf("%d",&b); if( b > 99999 ) continue; if(b%2==0) { printf("數值%d為偶數\n",b); } else { printf("數值%d為奇數\n",b); } if( b <= 0 ) break; } system("pause"); }
2013/12/16作業2
#include <stdio.h> #include <stdlib.h> int main(void) { int b,c; int a[10]={10,20,30,40,50,60,70,70,80,90}; printf("請輸入數值:"); scanf("%d",&b); for(c=0;c<=9;c++) if(b==a[c]) printf("數值在第%d位置",c+1); system("pause"); }
2013/12/16作業
#include <stdio.h> #include <stdlib.h> int main(void) { int a,b,c; printf("請輸入長寬:"); scanf("%d",&a); scanf("%d",&b); printf("長:%d \n",a ); printf("寬:%d \n",b ); printf("面積:%d \n",a*b ); system("pause"); }
2013/12/2作業
#include <stdio.h> #include <stdlib.h> main(){ int i=0,max=0,a=0; int b[]={35,100,20,10,50,60,75,88,25,5}; for(i=0;i<=10;i++) { if (b[i]>max) max=b[i]; if (b[i]<max) a=b[i]; } printf("最大值: %d \n",max); printf("最小值: %d \n",a); system("pause"); }
2013/11/25作業
#include <stdio.h> #include <stdlib.h> main(){ int k=0; int b[10]={10,20,30,40,50,60,70,80,90,100}; for(k=0;k<=9;k++) { printf("第 %d 值 %d\n" ,k+1, b[k]); printf("第 %d 位置 %d\n" ,k+1, &b[k]); printf("第 %d 大小 %d\n" ,k+1, sizeof(b[k])); } system("pause"); }
2013/10/21程式設計第三次作業
#include <stdio.h> #include <stdlib.h> int main(void) { for(int k = 0; k=10 ; k++){ int a,b,c,k; printf("請輸入數字:"); scanf("%d %d %d",&a,&b,&c); printf("第一個數字:%d \n",a ); printf("第二個數字:%d \n",b ); printf("第三個數字:%d \n",c ); printf("數字相乘:%d \n",a*b*c ); } system("pause"); }
2013/10/14程式設計第二次作業
main() { int x=20; int y=30; int z=40; char a= 'h'; char b= 'a'; char c= 'p'; char d= 'p'; char e= 'y'; printf("x 的位址 %x \n",&x ); printf("y 的位址 %x \n",&y ); printf("z 的位址 %x \n",&z ); printf("x 的值 %x \n",x ); printf("y 的值 %x \n",y ); printf("z 的值 %x \n",z ); printf("a 的位址 %x \n",&a ); printf("b 的位址 %x \n",&b ); printf("c 的位址 %x \n",&c ); printf("d 的位址 %x \n",&d ); printf("e 的位址 %x \n",&e ); printf("a 的值 %x \n",a ); printf("b 的值 %x \n",b ); printf("c 的值 %x \n",c ); printf("d 的值 %x \n",d ); printf("e 的值 %x \n",e ); system ("PAUSE"); }
2013/10/07程式設計第一次作業
#include <stdio.h> #include <stdlib.h> int main() { int a; int b; int c; int d; a = 6; b = 7; c = 24 ; d = a+b+c; printf("總數=%d\n",d); system("pause"); }
|
|