Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivanwangcy committed Nov 7, 2024
1 parent 0d9478b commit 69f2fe8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Binary file added cpp/rand
Binary file not shown.
30 changes: 30 additions & 0 deletions cpp/rand.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>


void mini_random() {
int current = 1;
int step = 2;
for (int i = 0; i < 100; i++) {
printf("%d\n", current);
current += step;
if (current > 100) {
break;
}
if (step == 1 || step == 3) {
step += 1;
} else if (step == 2 || step == 4) {
step -= 1;
}
}
}

int main(int argc, char const *argv[])
{
printf("%d, ", rand()% 1000);
srand(time(0));
printf("%d\n", rand()% 1000);
mini_random();
return 0;
}

0 comments on commit 69f2fe8

Please sign in to comment.