Last active
October 21, 2017 20:17
-
-
Save raqbit/f04ab1d040f5ff003f0300471c41e249 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
long long badsquare(long long n); | |
int main(int argc, char **argv) | |
{ | |
if(argc < 2) | |
{ | |
printf("Please enter the number to square\n"); | |
return 1; | |
} | |
printf("Not so regular square: %lld\n",badsquare(strtoll(argv[1],NULL,0))); | |
return 0; | |
} | |
long long badsquare(long long n) | |
{ | |
long long k = 0; | |
for(;;) | |
{ | |
if(k == n*n) | |
{ | |
return k; | |
} | |
k++; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
long long square(long long n); | |
int main(int argc, char **argv) | |
{ | |
if(argc < 2) | |
{ | |
printf("Please enter the number to square\n"); | |
return 1; | |
} | |
printf("Regular square: %lld\n",square(strtoll(argv[1],NULL,0))); | |
return 0; | |
} | |
long long square(long long n) | |
{ | |
return n*n; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment