Accumulator
10 points Easy

I'll give you a flag if you can get a negative number by adding only positive numbers.

nc rivit.dev 10009

task.tar.gz
Flag
Rating 4.62
5
4
3
2
1

Discussion

hint: integer overflow

0

include <stdlib.h>

include <stdio.h>

int main(){ setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stdin, NULL, _IONBF, 0);

int acc = 0;
int n;
while (acc >= 0){
    printf("acc = %d\n", acc);
    printf("Enter a number: ");

    if (scanf("%d", &n) != 1){
        puts("Error reading integer");
    } else {
        if (n < 0){
            puts("You can't enter the negative number!");
        } else {
            acc += n;
        }
}
 // デバッグ用: 強制的にaccを負の値に設定
    if (acc >= 1000) {
        acc = -1;

    }
}

printf("You win! acc = %d\n", acc);
system("cat ./flag.txt");

}

-1

Chat gpt helped me whit this

-1

Solved without downloading the source file : )

0

Yooooooooooo, tambah tambah tambah sampai mentok

-1

Yooooooooooo, tambah tambah tambah sampai mentok

0

Yooooooooooo, tambah tambah tambah sampai mentok

0

Yooooooooooo, tambah tambah tambah sampai mentok

0

Yooooooooooo, tambah tambah tambah sampai mentok

0

Yooooooooooo, tambah tambah tambah sampai mentok

0

this really isn't hard it's just a 32 bit integer overflow

-12

Dont spoil the challenges ;) and yeah, thats why it it in "easy" category :)

5

Pls change the comment to protected. You are ruining it for other ppl.

2