info@sislbd.com +8801615 900004

Monthly Archives: May 2013

#include <stdio.h> int main() { long a,i,b,sum; while(scanf(“%ld”, &a) && a) { sum=0; i=0; if(a==1) printf(“The parity of 1 is 1 (mod 2).\n”); else { while(1) { b=a%2; a=a/2; i++; if(a==1) { b=0; b=1; break; } // End of if } //End of while printf(“The parity of “); for(long k=i-1;k>=0;k–) { if(b==1) sum=sum+1; printf(“%ld”,b); }

May 13, 2013

#include <stdio.h> #include <string.h> int main() { char str,c; long i,j,sum; while(scanf(“%s”,&str)!=EOF) { sum=0; i=strlen(str); for(j=0;j<i;j++) { for(c=97;c<=122;c++) if(str==c) sum=sum+(c-96); for(c=65;c<=90;c++) if(str==c) sum=sum+(c-38); }//End of 1st for long r,k; r=(long)sum/2; for(k=2;k<=r;k++) if(sum%k==0) break; if(i==1 && str==’a’) printf(“It is a prime word.\n”); else if(k==r+1) printf(“It is a prime word.\n”); else printf(“It is not a prime word.\n”);

May 13, 2013

#include <stdio.h> int main() { long N,s,d,score1,score2; scanf(“%ld”, &N); for(long count=1;count<=N;count++) { scanf(“%ld%ld”, &s, &d); if(s < d) printf(“impossible\n”); else { score1 = (s+d)/2; score2 = s-score1; if((s+d)%2 == 0 && score1 >= 0 && score2 >= 0) printf(“%ld %ld\n”,score1,score2); else printf(“impossible\n”); } } }

May 13, 2013

#include <stdio.h> int main() { long num,num_1,i=0,j,sum=0,c,a,N; scanf(“%ld”, &N); for(long k=1;k<=N;k++) { scanf(“%ld”, &num_1); if(num_1<10) num=num_1*num_1; else num=num_1;while(1) { c=num; do { num=num; a=num; i++; c=c/10; if(c<10) a=c;num=c; }while(c>9);//End of do-while for(j=i;j>=0;j–) sum=sum+a*a; num=sum; if(num<10) { if(num==1) printf(“Case #%d: %d is a Happy number.\n”,k,num_1); else printf(“Case #%d: %d is an Unhappy number.\n”,k,num_1); break; } sum=0;

May 13, 2013