Welcome Guest.

1Answers

Big guy’s help to change the program C ++

Asked by: Anthony White 24 views IT December 11, 2022

#include

int Main ()

{

int a, b;

Float Q;

scanf ("%d%d", &a, &b);

q = a*30+b/2+b%2-b*6;

if (q> 180)

{

q = 360-q;

}

if (q <0)

{

q = -q;

}

if (b <10)

Printf ("at%d: 0%d the angle is"%.1F "defrees. \ n", a, b, q);

Printf ("at%d:%d the angle is "%.1F" defrees. \ n ", a, b, q);

Return 0;

}

Addition: I do n’t understand the cause of error: in function 'main': main.c: 17: 37: Error: Invalid Operands to binary % (have 'char *' and 'float') printf ("at %d: 0%d the angle is "%.1F" degrees. \ n ", a, b, q); ^main.c: 17: 41: EXPECTED ')' Before String Constant Printf (" AT%D D%D: 0%d the angle is "%.1F" degrees. \ N ", a, b, q); ^main.c: 20: 33: error: invalid operats to binary%(have 'char *' and 'float') PRINTF ("AT%D:%D the angle is"%.1F "Degrees. \ n", a, b, q); ^main.c: 20: 37: error: expected') ')') ')') ')') ')') ')') ')') ')') ')BeFore String Constant Printf ("AT%D:%D the angle is"%.1F "defrees. \ n", a, b, q)', Declared with Attribute warn_unused_result [-wunused-Result] scanf (" %d %d", &a, &b); ^

1 Answers

  1. +1Votes  

    The modified (mainly multi -space and quotation marks)

    In addition, the less than 10 does not need to be judged, just use%02D

    Diana Anderson- December 11, 2022 |