31 lines
465 B
C
31 lines
465 B
C
#include "stdio.h"
|
|
|
|
int main()
|
|
{
|
|
|
|
/*
|
|
* modify 24 hour time to 12 hour
|
|
* take first 2 numbers,
|
|
* if numbers <=12, AM
|
|
* else PM
|
|
* */
|
|
|
|
int i ; int j; char c;
|
|
printf("input time: ");
|
|
scanf("%2d%1c%2d", &i,&c, &j);
|
|
printf("int i: %d int j: %d\n", i, j);
|
|
|
|
if(i!=12&&j==00){
|
|
i%=12;
|
|
}
|
|
|
|
|
|
if(i <=12){
|
|
printf("%d:%.2d AM",i,j);
|
|
} else {
|
|
printf("%d:%.2d PM",i,j);
|
|
}
|
|
|
|
return 0;
|
|
}
|