/* Note:Your choice is C IDE */
#include “stdio.h”
struct time
{
int hour;
int minutes;
int seconds;
};
int main( void )
{
struct time timeupdate ( struct time now );
struct currenttime; struct nexttime;
printf (“enter the time ( hh: mm: ss )”);
scanf (“%i:%i:%i”, ¤ttime.hour, ¤ttime.minutes, ¤ttime.seconds );
nexttime = timeupdate (currenttime);
printf (“updated time is %.2i:%.2i:%.2i\n”,nexttime.hour, nexttime.minutes, nexttime.seconds);
return 0;
}
struct time timeupdate ( struct time now )
{
++now.seconds;
if ( seconds == 60 ) {
now.seconds = 0;
++now.minutes;
if ( minutes == 60) {
now.minutes = 0;
++now.hour;
if ( now.hour == 24 ) {
now.hour = 0;
}
}
return now;
}
>> 本文固定链接: http://www.vcgood.com/archives/2751
钟表程序/》
/* Note:Your choice is C IDE */
#include “stdio.h”
struct time
{
int hour;
int minutes;
int seconds;
};
int main( void )
{
struct time timeupdate ( struct time now );
struct time currenttime; struct time nexttime;
printf (“enter the time ( hh: mm: ss )”);
scanf (“%i:%i:%i”, ¤ttime.hour, ¤ttime.minutes, ¤ttime.seconds );
nexttime = timeupdate (currenttime);
printf (“updated time is %.2i:%.2i:%.2i\n”,nexttime.hour, nexttime.minutes, nexttime.seconds);
return 0;
}
struct time timeupdate ( struct time now )
{
int seconds;
int minutes;
++now.seconds;
if ( seconds == 60 )
{
now.seconds = 0;
++now.minutes;
}
if ( minutes == 60)
{
now.minutes = 0;
++now.hour;
}
if ( now.hour == 24 )
{
now.hour = 0;
}
return now;
}
粗体为修改!
都是一些语法错误,小心就好了!