## Search found 12 matches

Sat Feb 22, 2003 7:39 pm
Forum: Algorithms
Topic: How can I use a bit to store a boolean value in C?
Replies: 3
Views: 2393
why not use Bit-Field?
Tue Oct 22, 2002 4:31 pm
Forum: Other words
Topic: help needed: matrix chain multiplication (reversed!)
Replies: 0
Views: 1402

### help needed: matrix chain multiplication (reversed!)

To calculate an optimal solution for matrix chain multiplication we have to make two tables : one for the cost ('m' table) and other one to take the point where to break ('s' table). Now given a sequence of matrix we can easily calculate an optimal solution. Now the question is that: If we are given...
Tue Sep 10, 2002 5:28 am
Forum: C
Topic: Round up float value
Replies: 5
Views: 2916

Code: Select all

``````char str[100];
sprintf(str,"%.2f",a);
a=atof(str);
// be sure u're not using Turbo C++.The atof function in it has bugs.
// u can write a subroutine also that does the same thing life atof.
``````
Imran
Wed Aug 07, 2002 5:27 pm
Forum: Volume 1 (100-199)
Topic: 160 - Factors and Factorials
Replies: 205
Views: 25663
Hi Razib.... There's nothing wrong about the method....u've done wrong with the printing. for(j=0;j<e;j++) { printf("%3ld",cn[j]); if(j==14) { printf("\n"); printf(" "); } look at ur code...there are 2 mistakes: i) when the output goes to the 2nd line u've printed less spaces (i'm not sure about it ...
Wed Jul 31, 2002 9:24 pm
Forum: Volume 3 (300-399)
Topic: 389 - Basically Speaking
Replies: 94
Views: 22949
Thank u very much....thanks a lot
Wed Jul 31, 2002 6:34 am
Forum: Volume 3 (300-399)
Topic: 389 - Basically Speaking
Replies: 94
Views: 22949

### Hellow.......anyone alive to help me on 389

Mon Jul 29, 2002 7:10 am
Forum: Volume 3 (300-399)
Topic: 389 - Basically Speaking
Replies: 94
Views: 22949
The problem description clearly says: The project manager of the Super Neato Model I calculator has informed you that the calculator will have the following neato features: It will have a 7-digit display. Its buttons will include the capital letters A through F in addition to the digits 0 through 9....
Sun Jul 28, 2002 8:24 pm
Forum: Volume 3 (300-399)
Topic: 389 - Basically Speaking
Replies: 94
Views: 22949

### 389 - Basically Speaking

Why does my program give WA again and again and again....... /* @JUDGE_ID:XXXXXX 389 C++ */ #include<stdio.h> #include<string.h> #include<ctype.h> char str[100]; long from,to; long num; long power(long b,long n) { long i,p=1; for(i=0;i<n;i++) p=p*b; return p; } void str_rev(char *s) { long i,j; j=st...
Sun Jul 28, 2002 5:01 pm
Forum: Volume 4 (400-499)
Topic: 412 - Pi
Replies: 104
Views: 18356
Dear htl....

I think the problem is in the gcd function....

suppose you are going to calculate gcd(3,1)
then x=3,y=1 and as a=x and b=y a=3 and b=1

So, in the loop r=a%b=3%1 (!) and gcd returns a=3
But gcd(3,1) should be 1, isn't it?
Mon Jul 22, 2002 3:02 pm
Forum: Volume 1 (100-199)
Topic: 160 - Factors and Factorials
Replies: 205
Views: 25663
There are two problems: i) There is an extra space after the '=' sign in each step and also when you printed the newline character along with some spaces. here---->>printf("%3d! = ", fact); for (i = 0; i < 25; i++) { if (i == 15) here----->>printf("\n "); if (factors[i] == 0) break; printf("%3d", fa...
Fri Jul 19, 2002 7:17 pm
Forum: Volume 1 (100-199)
Topic: 160 - Factors and Factorials
Replies: 205
Views: 25663
The problem is right here:
you increased count every time.
But you should have increased count whenever you print a digit.

for(x=0,count=1;x<25;x++,count++)
{
if(ans[x]!=0)
printf("%3d",ans[x]);
if(count%15==0)
printf("\n ");
}
Fri Jul 19, 2002 6:37 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 188040

### Fix the input taking part

There's nothing wrong in the logic..but the way of taking input is not right.

change the code of taking input :

replace the lines -> while(!feof(stdin))
and -> scanf("%d%d",&min,&max)

write it in the following way:

while(2==scanf("%d%d",&min,&max))

and your program will get accepted.