标签:ret pre nbsp alt gif http stdio.h class c++
#include<stdio.h> int main() { int sign(int x); int x,y; scanf("%d",&x); y=sign(x); printf("sign(%d)=%d\n",x,y); return 0; } int sign(int x) { int y; if(x>0) y=1; else if(x==0) y=0; else y=-1; return y; }
#include<stdio.h> #include<math.h> int main() { int c,i,m,n,sum; int prime(int m); scanf("%d%d",&m,&n); c=sum=0; for(i=m;i<=n;i++) if(prime(i)!=0) { c++; sum=sum+i; } printf("c=%d,sum=%d\n",c,sum); return 0; } int prime(int m) { int j,i; if(m==1) return 0; j=sqrt(m); for(i=2;i<=j;i++) if(m%i==0) return 0; return 1; #include<stdio.hint main(void)
{ int c,digit,in; int countdigit(int number,int digit); scanf("%d%d",&in,&digit); c=countdigit(in,digit); printf("number %d of digit %d:%d\n",in,digit,c); return 0; } int countdigit(int number,int digit) { int c; if(number<0) number=-number; c=0; do{ if(number%10==digit) c++; number=number/10;}while(number!=0);
return c;
}
#include<stdio.h> int main(void) { int i,m,n; int is(int number); scanf("%d%d",&m,&n); printf("result:\n"); for(i=m;i<=n;i++) if(is(i)!=0) printf("%d\n",i); return 0; } int is(int number) { int digit,sum,temp; temp=number; sum=0; while(temp!=0){ digit=temp%10; temp=temp/10; sum=sum+digit*digit*digit; } return sum==number; }
#include<stdio.h> int even(int n); int main(void) { int n,sum; scanf("%d",&n); sum=0; while(n>0){ if(even(n)==0) sum=sum+n; scanf("%d",&n); } printf("The sum of the odd numbers is %d.\n",sum); return 0; } int even(int n) { int y; if(n%2==0) y=1; else y=0; return y; }
标签:ret pre nbsp alt gif http stdio.h class c++
原文地址:http://www.cnblogs.com/YuzurihaInori/p/6116134.html