At Saturday 11/24/2007 01:48 AM, you wrote:
>hi
>
>~Rick <[EMAIL PROTECTED]> wrote:          At 
>Thursday 11/22/2007 09:46 AM, you wrote:
> >Hi,everyone .When I try to change decimal number into other type numbers.
> > I write it like as follow:
> >
> >
> > int main()
> >{
> > int integer;
> > int a[100] = {0};
> > static double account = 0;
> > int i ;
> > double ii = 0;
> > double number = 0;
> > double digit;
> > printf("Enter one decimal number");
> > scanf("%d",&integer);
> > printf("Enter one number as digit you want to change to");
> > scanf("%lf",&digit);
> >
> > while (number <= integer)
> > {
> > number = pow(digit, account);
> > account += 1;
> > }
> >
> >
> >
> > for(i = account;i >= 0;i--)
> > {
> > ii = i;
> > a[i] = integer / pow(digit, ii);
> > integer = integer - pow(digit, ii) * a[i];
> > }
> > printf("\n%d",account); //I am puzzled here
> >
> > printf("\nThe %.0f number you need is ", digit);
> > for(i = (account - 2);i >= 0;i--)
> > {
> > if (a[i] == 10)
> > printf("A");
> > else if (a[i] == 11)
> > printf("B");
> > else if (a[i] == 12)
> > printf("C");
> > else if (a[i] == 13)
> > printf("D");
> > else if (a[i] == 14)
> > printf("E");
> > else if (a[i] == 15)
> > printf("F");
> >
> > if ((a[i] == 10)||(a[i] == 11)||(a[i] == 12)
> > ||(a[i] == 13)||(a[i] == 14)||(a[i] == 15))
> > continue;
> >
> > printf("%d", a[i]);
> > }
> >
> > return 0;
> >}
> >
> >
> > But I am puzzled by the VALUE
> > of account .I print it after the first while
> > loop , but its value still keeps as 0.I think it should be some number != 0
> > And if I want to print the result I have to
> > initialize i as (account - 2) ,otherwise
> > it will print two 0 before the right answer .Why ?
> >
>
>You have defined "account" to be of type double. Try
>
>printf("\n%52.f",account); //I am puzzled here

Ummm, sorry. That should have been %5.2f not %52.f

~Rick

> >
> >---------------------------------
> > @yahoo.cn ÐÂÓòÃû¡¢ÎÞÏÞÁ¿£¬¿ìÀ´ÇÀ×¢£¡
> >
> >[Non-text portions of this message have been removed]
> >
> >
> >
> >To unsubscribe, send a blank message to
> ><mailto:[EMAIL PROTECTED]>.
> >Yahoo! Groups Links
> >
> >
> >
>
>
>
>
>
>
>---------------------------------
>Be a better sports nut! Let your teams follow 
>you with Yahoo Mobile. Try it now.
>
>[Non-text portions of this message have been removed]
>
>
>
>To unsubscribe, send a blank message to 
><mailto:[EMAIL PROTECTED]>.
>Yahoo! Groups Links
>
>
>

Reply via email to