¾«Æ·Îĵµ
if (a>0) p++; else if (a<0) n++; else z++; }
printf(\ÕýÊý£º], ¸ºÊý£º],Á㣺]\\n\
}
7¡¢±à³ÌÐòʵÏÖÇó1-10Ö®¼äµÄËùÓÐÊýµÄ³Ë»ý²¢Êä³ö¡£
#include
long sum=1; for(i=1; i<=10; i=i+1) sum=sum*i;
printf(¡°the sum of odd is :%ld¡±,sum); }
8. ´Ó¼üÅÌÉÏÊäÈë10¸öÊý£¬ÇóÆäƽ¾ùÖµ¡£ #include
int a,i,sum=0; float ave;; for(i=0;i<10;i++){
scanf(\
¾«Æ·Îĵµ
¾«Æ·Îĵµ
sum+=a; }
ave=(float)sum/10;
printf(\ }
9¡¢±à³ÌÐòʵÏÖÇó1-1000Ö®¼äµÄËùÓÐÆæÊýµÄºÍ²¢Êä³ö¡£
#include
printf(¡°the sum of odd is :%d¡±,sum); }
10.ÓÐÒ»¸ö·ÖÊýÐòÁУº2/1£¬3/2£¬5/3£¬8/5£¬13/8£¬¡¡±à³ÌÇóÕâ¸öÐòÁеÄǰ20ÏîÖ®ºÍ¡£ #include
¾«Æ·Îĵµ
¾«Æ·Îĵµ
t=a; a=a+b; b=t; }
printf(\}
11£®´Ó¼üÅÌÊäÈëÁ½¸öÊý£¬Çó³öÆä×î´óÖµ£¨ÒªÇóʹÓú¯ÊýÍê³ÉÇó×î´óÖµ£¬
²¢ÔÚÖ÷º¯ÊýÖе÷Óøú¯Êý£© #include
scanf(\m=max(a,b); printf(\}
float max(float x,float y) {
if (x>=y) return x;
¾«Æ·Îĵµ
¾«Æ·Îĵµ
else return y; }
12. ±àд³ÌÐò£¬ÆäÖÐ×Ô¶¨ÒåÒ»º¯Êý£¬ÓÃÀ´ÅжÏÒ»¸öÕûÊýÊÇ·ñÎªËØÊý£¬Ö÷º¯ÊýÊäÈëÒ»¸öÊý£¬Êä³öÊÇ·ñÎªËØÊý¡£
#include
int IsPrimeNumber(int number) { int i;
if (number <= 1)
return 0;
for (i=2; i return 0; } return 1;} void main() { int n; printf(¡°Please input n:¡±); scanf(¡°%d¡±,&n); if(IsPrimeNumber(n)) printf(¡°\\n%d is a Prime Number¡±,n); ¾«Æ·Îĵµ