buzZsk 发表于 2013-3-9 12:11 PM
以一种飞机来做example咯
网上很多飞机的资料吧
http://library.thinkquest.org/04oct/00450/typeso ...
black7white 发表于 2013-3-22 11:40 PM
关于return的,那么void 的function不用return,不就代表没有交还给公司咯?怎么行呢?
void没交还,所 ...
#include <stdio.h>
int input();
int main(){
int num,i,flag;
num=input(); /* No argument is passed to input() */
for(i=2,flag=i;i<=num/2;++i,flag=i){
if(num%i==0){
printf("%d is not prime",num);
++flag;
break;
}
}
if(flag==i)
printf("%d is prime",num);
return 0;
}
int input(){ /* Integer value is returned from input() to calling function */
int n;
printf("Enter positive enter to check:\n");
scanf("%d",&n);
return n;
}
#include <stdio.h>
int check(int n);
int main(){
int num,num_check=0;
printf("Enter positive enter to check:\n");
scanf("%d",&num);
num_check=check(num); /* Argument num is passed to check() function. */
if(num_check==1)
printf("%d in not prime",num);
else
printf("%d is prime",num);
return 0;
}
int check(int n){
/* Integer value is returned from function check() */
int i;
for(i=2;i<=n/2;++i){
if(n%i==0)
return 1;
}
return 0;
}
欢迎光临 JBTALKS.CC (https://www.jbtalks.cc/) | Powered by Discuz! X2.5 |