0
点赞
收藏
分享

微信扫一扫

C语言time函数,指针

蚁族的乐土 2022-01-24 阅读 58
c语言
#include <stdio.h>
#include <stdlib.h>
void time(int,int*,int*,int*);
int main(int argc, char *argv[]) {
	//define
    int seconds,hours,min,sec;
    //input
    printf("please input an integer number of seconds:\n");
    scanf("%d",&seconds);
    //call the function
    time(seconds,&hours,&min,&sec);
    //output
    printf("%dhours %dminutes %dseconds\n",hours,min,sec);
	system("pause");
	return 0;
}
void time(int a,int*h,int*m,int*s){
	*h=a/3600;
	*m=a/60-*h*60;
	*s=a-*m*60-*h*3600;
}
举报

相关推荐

0 条评论