made 3xplus1 take args
i think this code is kinda messy but it works @quantum HELPHELPHELPHELPHELP
This commit is contained in:
parent
0fe2d7cf14
commit
39e75a6b2b
2 changed files with 19 additions and 3 deletions
22
3xplus1.c
22
3xplus1.c
|
@ -1,9 +1,25 @@
|
|||
#include <stdio.h> //printf and shit
|
||||
|
||||
int main(){
|
||||
//asd
|
||||
int main( int argc, char *argv[] ) { //yoinked from the internet argc is number of args and argv is a "array of arguments"
|
||||
|
||||
int x; //idk what types are i think this is a 32bit signed int... idk @quantum help... also should this even be here or should it be out of main
|
||||
x = 69;
|
||||
|
||||
if(argc != 2){
|
||||
puts("fix your arguments");
|
||||
return 0; //idk if this is how i should return an error idk @quantum rip my code to shreads
|
||||
}
|
||||
|
||||
x = atoi(argv[1]);
|
||||
|
||||
if(x == 0){
|
||||
puts("uhhhh you entered 0 this wont end");
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
printf("Got: %d\n", x);
|
||||
}
|
||||
|
||||
|
||||
while(x != 1){ //while x is not true i think
|
||||
printf("%d\n",x );
|
||||
if(x & 1 == 1){ //if x is odd
|
||||
|
|
BIN
a.out
BIN
a.out
Binary file not shown.
Loading…
Reference in a new issue