/ SeriousOJ /

Record Detail

Compile Error

foo.c: In function 'main':
foo.c:7:15: error: 't_' undeclared (first use in this function)
    7 |         while(t_ _){
      |               ^~
foo.c:7:15: note: each undeclared identifier is reported only once for each function it appears in
foo.c:7:17: error: expected ')' before '_'
    7 |         while(t_ _){
      |              ~  ^~
      |                 )
foo.c:10:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'cost'
   10 |                 int total cost = 0;
      |                           ^~~~
foo.c:10:27: error: 'cost' undeclared (first use in this function)
foo.c:12:25: error: unknown type name 'total'
   12 |                         total cost = N * A;
      |                         ^~~~~
foo.c:15:25: error: unknown type name 'total'
   15 |                         total cost = D * A;
      |                         ^~~~~
foo.c:16:25: error: unknown type name 'total'
   16 |                         total cost = (N - D)*B;
      |                         ^~~~~
foo.c:16:31: error: redefinition of 'cost'
   16 |                         total cost = (N - D)*B;
      |                               ^~~~
foo.c:15:31: note: previous definition of 'cost' with type 'int'
   15 |                         total cost = D * A;
      |                               ^~~~
foo.c:18:32: error: 'total' undeclared (first use in this function)
   18 |                 printf("%d\n", total cost);
      |                                ^~~~~
foo.c:18:37: error: expected ')' before 'cost'
   18 |                 printf("%d\n", total cost);
      |                       ~             ^~~~~
      |                                     )
foo.c:20:1: error: expected declaration or statement at end of input
   20 | }
      | ^

Code

#include <stdio.h>

int main()
{
    int T;
	scanf("%d", &T);
	while(t_ _){
		int N, D, A, B;
		scanf("%d %d %d %d", &N, &D, &A, &B);
		int total cost = 0;
		if (N <= D){
			total cost = N * A;
		}
		else {
			total cost = D * A;
			total cost = (N - D)*B;
		}
		printf("%d\n", total cost);
			return 0;
}

Information

Submit By
Type
Submission
Problem
P1090 Summer trip
Contest
Brain Booster #5
Language
C99 (GCC 13.2.0)
Submit At
2024-09-05 15:46:52
Judged At
2024-10-03 13:10:25
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes