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> | |
int main() | |
{ | |
const size_t size = 1000; | |
char *line = NULL; | |
FILE *infile = NULL; | |
int status = 1; /* assume failure unless everything succeeds */ | |
double a, b, c, sum; |
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> | |
int main() | |
{ | |
const size_t size = 1000; | |
char *line; | |
FILE *infile; | |
double a, b, c, sum; |
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
for (i=0; i<3; ++i) | |
{ | |
for (j=0; j<3; ++j) | |
{ | |
if (a[i][j] < 0) | |
goto stop_printing; | |
printf(" %9d", a[i][j]); | |
} | |
printf("\n"); | |
} |
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
valid = 1; | |
for (i=0; i<3; ++i) | |
{ | |
for (j=0; j<3; ++j) | |
{ | |
if (a[i][j] < 0) | |
{ | |
valid = 0; | |
break; | |
} |
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
for (i=0; i<3; ++i) | |
{ | |
for (j=0; j<3; ++j) | |
{ | |
printf(" %9d", a[i][j]); | |
} | |
printf("\n"); | |
} | |
/* ... remaining code ... */ |
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
#!/usr/bin/env python3 | |
import sys | |
import exifread # sudo pip3 install exifread | |
def GpsEval(v): | |
factor = 1.0 | |
sum = 0.0 | |
for r in v: | |
sum += factor * (r.num / r.den) | |
factor /= 60.0 |
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
from enum import IntEnum | |
class ImageFormat(IntEnum): | |
PNG = 1 | |
JPEG = 2 | |
GIF = 3 |
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
from enum import Enum, unique | |
@unique | |
class Suit(Enum): | |
Club = 1 | |
Diamond = 2 | |
Heart = 3 | |
Spade = 4 | |
@unique |
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
def React(suit): | |
if suit == Suit.Club: | |
print('Please do not beat me with that.') | |
elif suit == Suit.Diamond: | |
print('Now we are rich.') | |
elif suit == Suit.Heart: | |
print('I love you too.') | |
elif suit == Suit.Spade: | |
print('Thank you for the handy garden tool.') | |
else: |
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
@unique | |
class Suit(Enum): | |
Club = 1 | |
Diamond = 1 # Oops! | |
Heart = 3 | |
Spade = 4 |