爱生活

 找回密码
 立即注册
搜索
查看: 96|回复: 0
打印 上一主题 下一主题

c语言怎么样编写一个时钟程序,怎么编写一个时间程序

[复制链接]

14万

主题

14万

帖子

-134万

积分

限制会员

跳转到指定楼层
楼主
发表于 2023-2-17 01:00:01 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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 ;
}




上一篇:速冻的水饺怎么做水煎饺?,水饺怎么做成煎饺
下一篇:天麻栽培方法,天麻怎么栽培
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)

站点统计|手机版|小黑屋|爱生活 ( 蜀ICP备20006951号 )|

 

快速回复 返回顶部 返回列表