Tuesday 12 January 2016

Solution of URI 1958 :: Scientific Notation


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/
 
#include <stdio.h>
int main()
{
    long double X;
    char s[120];
    scanf("%LE", &X);
    sprintf(s,"%LE", X);
    if(s[0] != '-') printf("+");
    printf("%.4LE\n", X);
    return 0;
}

12 comments:

  1. I couldn't understand what is sprintf and why u made the condition and why in the last printf u wrote %4.LE instead of %LE ?

    Thanks :) Alsalam Alaykom

    ReplyDelete
    Replies
    1. Walaikum Assalam.
      * sprintf converts double into string.
      * When you print +5, your PC shows you just 5.
      * So, i make this condition when the number is positive, it prints a "+" at first.
      * I use %.4LE, because it prints four digit after decimal point(.).
      and you are welcome. :)

      Delete
  2. Thank you very much,brother.You codes are helping me as a great guideline.

    ReplyDelete
    Replies
    1. and You are most welcome...........
      :)

      Delete
    2. bro number system convert korer naki akta function ase....janale khosi hvo...ar sprintf ar moto ar ki kono function ase?

      Delete
  3. #include
    int main()
    {
    long double num;
    scanf("%LE", &num);
    if(num>=0.0000E+00)
    printf("+");
    printf("%.4LE\n", num);
    return 0;
    }
    ai code ta 10% wa dissi kno?akto bolben?

    ReplyDelete
    Replies
    1. Have a case in this problem, that is -0.0000 and you need print +0.0000, but your code produces +-0.0000, (I think that is it case, but to take the doubt, check the toolkit).

      Delete
  4. alsalam alaykom
    thank you very much for helping us and actually remind me to tools in language that's help me in problems

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. #include
    int main()
    {
    double X;
    scanf("%lf",&X);
    printf("%.4E\n",X);
    return 0;
    }

    ReplyDelete
  7. vaiia ai dike %LE er kaj ki??

    ReplyDelete
  8. aita C++ -a kivabe korbo??

    ReplyDelete

Note: only a member of this blog may post a comment.