Created
June 20, 2010 06:51
-
-
Save johnhmj/445630 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> | |
unsigned int TexiCounter(double distance); | |
void main(int argc, char** argv) | |
{ | |
double dis = 0.0; | |
printf("Input Texi distance: "); | |
scanf("%lf", &dis); | |
printf("Money = $%d.-\n", TexiCounter(dis));; | |
system("PAUSE"); | |
} | |
unsigned int TexiCounter(double distance) | |
{ | |
unsigned int nReturn = 100; | |
if ( distance < 0.0 ) | |
{ | |
distance = 0.0 - distance; | |
} | |
if ( distance > 2.0 ) | |
{ | |
distance -= 2.0; | |
nReturn += ((unsigned int) (distance / 0.5) * 5); | |
distance -= (unsigned int) distance; | |
if ( distance > 0.0 ) | |
{ | |
nReturn += 5; | |
} | |
} | |
return nReturn; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment