-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMisiRahasia.c
More file actions
31 lines (29 loc) · 815 Bytes
/
Copy pathMisiRahasia.c
File metadata and controls
31 lines (29 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <stdlib.h>
//#include "tester.h"
/* Tulis kode disini jika perlu */
int main() {
init();
/* Tulis kode dibawa ini */
// TODO: baca file input.txt
// TODO: tulis kode untuk algoritma utama
// TODO: close file input.txt
FILE *f = fopen("input.txt", "r");
int id, success, value;
fscanf(f, "%d %d %d", &id, &success, &value);
int total = 0;
int berhasil = 0;
int valuetot = 0;
while(id != -1){
total++;
if(success == 1){
berhasil++;
valuetot += value;
}
fscanf(f, "%d %d %d", &id, &success, &value);
}
printf("Total Misi: %d\n", total);
printf("Misi Berhasil: %d\n", berhasil);
printf("Total Nilai Misi: %d\n", valuetot);
return 0;
}