爱生活
标题:
c语言怎么样编写一个时钟程序,怎么编写一个时间程序
[打印本页]
作者:
123
时间:
2023-2-17 01:00
标题:
c语言怎么样编写一个时钟程序,怎么编写一个时间程序
c语言怎么样编写一个时钟程序
c语言时钟程序代码如下:
#include<windows.h>
#include<math.h>
#define ID_TIMER 1//计时器ID
#define TWOPI (2*3.14159)
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR szCmdLine,int iCmdShow)
{
static TCHAR szAppName[]=TEXT("Clock");
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WndProc;
wndclass.lpszClassName=szAppName;
wndclass.lpszMenuName=NULL;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("This program requires Windows
T"),szAppName,MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(szAppName,TEXT("Analog Clock"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAU
C语言编写由键盘输入设定计算机时钟当前时间的程序
我同意楼上说的 计算机时钟和当前时间不是一个概念
但是我猜你应该是想修改当前时间,代码如下
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define time_len 20
int main ()
{
char set_time[time_len], cmd[100];
printf("请输入想设置的时间(格式XX:xx):");
scanf("%s", &set_time); //输入将时间修改为XX:XX,其实可以不设置分,直接XX,则默认XX:00
strcpy(cmd, "time ");
strcat(cmd, set_time);
system(cmd);
}
编写一个程序,根据当前时间,显示“上午好”、“下午好”、或者“晚上好!”,并显示当前时间
用asp.net编写
代码如下:
<%@ page language="java"
contentType = "text/html; charset=UTF-8"
pageEncoding = "UTF-8"%>
<%@ page import ="java.util.Calendar" %>
<!DOCTYPE html>
<html>
<head>
<meta charset = "ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH) + 1;
int date = c.get(Calendar.DATE);
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
int second = c.get(Calendar.SECOND);
String str = "";
if(hour >= 0 && hour <=11){
&nbs
编一个显示时间的程序,可以精确表示年、月、日、时、分、秒?
#include<iostream>
using namespace std ;
typedef struct
{
int year ;
int month ;
int day;
int hour ;
int minute ;
int second ;
} Time ;
int main()
{
Time *time = new Time() ;
cout << "请输入年:" ;
cin >> time->year ;
cout << "请输入月:";
cin >> time->month ;
cout << "请输入日:";
cin >> time->day ;
cout << "请输入时:";
cin >> time->hour ;
cout << "请输入分钟:" ;
cin >> time->minute ;
cout << "请输入秒:" ;
cin >> time->second ;
//Display
cout << time->year << " 年 " << time->month << " 月 " << time->day << " 日 "
<< time->hour << " 时 " << time->minute << " 分 " << time->second << " 秒" << endl ;
return 0 ;
}
欢迎光临 爱生活 (https://ish.ac.cn/)
Powered by Discuz! X3