Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main()
- {
- int hh;
- char mm[10];
- const char str[80];
- char *token;
- while ((fscanf(stdin, "%s", str)) != EOF) {
- token = strtok(str, ".");
- hh = atoi(token);
- token = strtok(NULL, ".");
- strcpy(mm , token);
- if ( hh == 0 )
- {
- printf( "%d.", hh+12 );
- printf( "%sam\n", mm );
- } else if ( 0 < hh && hh < 12 ) {
- printf( "%d.", hh );
- printf( "%sam\n", mm );
- } else if ( 12 == hh ) {
- printf( "%d.", hh );
- printf( "%spm\n", mm );
- } else if ( 12 < hh && hh < 24) {
- printf( "%d.", hh-12 );
- printf( "%spm\n", mm );
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement