今日记录

#import <Foundation/Foundation.h>

 

int main(int argc, const char * argv[])

{

    //1.打印1-100中不能被7整除又不包含7的数

    //1>首先不能被7整除

    //2>去掉17,27,37....97

    //3>去掉71-79

//    for (int i = 1; i<=100; i++)

//    {

//        if (i%7 != 0 && i%10 != 7 && i/10 != 7)

//        {

//            printf("%d\n",i);

//        }

//    }

    

//    2.输入两个数,求最小公倍数和最大公约数

    //1>先求出最小公倍数:一定在最大的数和两个数的乘积之间比较

//    int num1, num2 = 0;

//    printf("please input two number.\n");

//    scanf("%d%d",&num1,&num2);

//    int max = num1>num2?num1:num2;

//    for (int i = max;max<=num1*num2 ; i++)

//    {

//        if (i % num1 == 0 && i % num2 == 0) {

//            printf("最小公倍数为:%d",i);

//            break;

//        }

//    }

    //2>再求出最小公约数:比较两个数中最小的那个

//    int min = num1<num2?num1:num2;

//    for (int j = min; j>=1; j--)

//    {

//        if (num1 % j == 0 && num2 % j == 0 )

//        {

//            printf("最大公约数为:%d",j);

//            break;

//        }

//    }

 

//    3.随机产生20个[10,100]的正整数,输出这些数以及他们中的最大数

//    unsigned int a = 0;

//    int max = 0;

//    for (int i = 1; i<=20; i++)

//    {

//        a =arc4random();

//        int c = a%91+10;

//        printf("c=%d\n",c);

//        if (max<c) {

//            max = c;

//        }

//    }

//    printf("max=%d\n",max);

//    4.编程将所有"水花仙数"打印出来,并打印其总个数,"水花仙数"是一个各个位立方之和等于该整数的三位数

    int num = 100;

    int count = 0;

    for (int i = num; i<=999; i++)

    {

        int a = i % 10;//个位

        int b = (i/10)%10;//十位

        int c = (i/10)/10;//百位

        if (i == a*a*a+b*b*b+c*c*c)

        {

            printf("%d\n",i);

            //printf("%d%d%d\n",c,b,a);

            count++;

        }

    }

    printf("count=%d\n",count);    

    

   // 5.使用循环打印三角形

    for (int i = 0; i<=3; i++) {

        for (int j = 0; j<3-i; j++) {

            printf(" ");

        }

        for (int k  = 0; k<2*i-1; k++) {

            printf("*");

        }

        printf("\n");

    }

    //6.输入一行字符,分别统计出其中英文字母.空格.数字和其他字符的个数

    //1>输入一行字符,计算这行字符数

//    int count = 0;//用来计数英文字母的个数

//    int count1 = 0;//用来计数空格的个数

//    int count2 = 0;//用来计数数字的个数

//    int count3 = 0;//用来计数其他的个数

//    char receieve = '\0';//用来接收读入字符

//    printf("please input a string:\n");

//    for (int i = 1; ; i++) {

//        receieve = getchar();

//        if ((receieve>='a' && receieve<='z')||(receieve>='A' && receieve<='Z')) {

//            count++;

//        }else if(receieve == ' '){

//            count1++;

//        }else if(receieve>='0' && receieve<='9'){

//            count2++;

//        }else if (receieve == '\n'){

//            break;//跳出循环的条件必须具备,否则循环没法停止

//        }else{

//            count3++;

//        }           

//    }

//    printf("英文字母个数为:%d,空格个数为:%d,数字个数为:%d,其他个数为:%d",count,count1,count2,count3);

    

//7.求S(n)=a+aa+aaa+aaaa+....+aa..a之值,其中a是一个数字,n表示a的位数例如:2+22+222+222+22222(此时n=5),n和a都从键盘输入

    

    //1>先输出a,aa,aaa

    //2>for循环执行的顺序:假设输入n=3,a=2,解释执行顺序:首先外层for满足i<=n,执行number=0*10+2=2,打印出2;下面的for循环暂不执行,执行sum1=0+0;然后执行i++,即i=2,number=2*10+2=22,打印出22;嵌套的for循环开始执行,sum=22+2,然后执行j++,即j=2,不满足j<i,跳出循环;执行sum1=0+22+2;然后执行i++,即i=3,number=22*10+2=222,打印出222;嵌套的for循环开始执行,sum=222+2,然后执行j++,即j=3,不满足j<i,跳出循环;执行sum1=22+2+222+2;然后执行i++,即i=4,不满足条件i<=n,即循环结束

//    int n = 0,a = 0;

//    printf("please enter two number:\n");

//    scanf("%d%d",&n,&a);

//    long int number = 0;//定义一个数值表示a, aa..aa

//    long int sum = 0;//在循环内控制部分数字的和,尤其是初始值

//    long int sum1 = 0;//求和

//    for (int i = 1; i<=n; i++)

//    {

//        number = number*10+a;

//        printf("number=%ld\n",number);

//        for (int j = 1; j<i; j++)

//        {

//           sum = number+a;

//        }

//        sum1=sum1+sum;

//        

//    }

//    printf("sum1=%ld\n",sum1-(n-2)*a);

    //8 :求 1!+2!+3!+4!……….20!

    //1>首先求出阶乘数1! ,2! ,3!....20!

    //2>将各个阶乘数依次相加

//    long int num = 1;

//    long int sum = 0;

//    for (long int i = num; i<=20; i++) {

//        num = num * i;

//        //printf("num=%ld\n",num);

//        sum = sum + num;

//    }

//    printf("sum=%ld\n",sum);

    //9: 有一个球,从100m高度自由落下,每次落地后反跳回原来高度的一半,在落下,再反弹,求它第十次落地时,共经过多少米?第十次反弹多高?

    //十次循环,将每次跳跃的高度,打印出来

//    float height = 100.00;

//    float Height = 0.00;//十次落地总计的路程

//    for (int i = 0; i<10; i++) {

//        height = height/2;

//        //printf("height=%.8f\n",height);

//        if (i == 9) {

//            printf("height=%f\n",height);//第十次反弹的高度

//        }

//        

//        Height = height*2+Height;

//    }

//    printf("Height=%f\n",Height+100);

    

    //10:猴子偷桃问题,猴子第一天摘下若干个桃子,当即吃掉一半,还不过瘾,又多吃了一个,以后每天都吃掉剩下的桃子的一半零一个,到第十天在想吃的时候就只剩下一个桃子了,求第一天共摘了多少个桃子?(摘桃子的那天为第一天!)

//    int count = 1;//总计的桃子数目

//    //第一天:cout/2+1,剩余:count-(count/2+1)

//    //第二天:(count-(count/2+1))/2+1

//    //倒着算

//    for (int i = 1; i<10; i++) {

//        count = 2(count+1);//最后剩余的一个留出来,每次加1

//    }

//    printf("count=%d\n",count);

    

    

    

    //面试题1 :输入十个数打印第二个大的数

    //1>定义三个变量,将最大的存入第二大变量中

//    int a = 0;

//    int max = 0;

//    int max1 = 0;//第二大数

//    printf("please enter 10 positive number:");

//    for (int i = 0; i<10; i++)

//    {

//        do

//        {

//          scanf("%d",&a);

//        } while (a<=0);

//        if (max<a)

//        {

//            max1 = max;

//            max = a;

//        }else if(max == a){

//            

//        }else if (max1<a){

//            max1 = a;

//        }

//        

//    }

//    printf("max1=%d\n",max1);//打印出第二大的数

 

 

    //面试题2:输入一个数,判断是几位数,倒着输出这几个数

    //1>将输入的数看做一个字符,用getchar()去存取和读出,判断它是否为数字,计算出相应的位数

    

//    int a = 0;

//    int count = 0;

//    do {

//        printf("please input a positive number:");

//        scanf("%d",&a);

//    } while (a<=0);

//        for (;a>0;a/=10)//计算每个数依次除10 ,而后再对十取余,就求出个位的数值,然后就实现逆序输出了

//    {

//        printf("%d",a%10);

//        count++;

//    }

//    printf("   count=%d\n",count);

 

转载于:https://www.cnblogs.com/yuanyuandachao/p/3343423.html

<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>企业员工打卡系统</title> <!-- 引入Element Plus样式 --> <link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css"> <style> * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', Arial, sans-serif; } body { background-color: #f5f7fa; color: #333; line-height: 1.6; padding: 20px; } .container { max-width: 1000px; margin: 0 auto; padding: 20px; } header { text-align: center; margin-bottom: 30px; padding: 20px 0; border-bottom: 1px solid #ebeef5; } h1 { color: #409eff; font-size: 28px; margin-bottom: 10px; } .dashboard { display: flex; gap: 20px; margin-bottom: 30px; } .clock-card { flex: 1; background: #fff; border-radius: 8px; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); padding: 25px; transition: all 0.3s; } .clock-card:hover { transform: translateY(-5px); box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.15); } .card-title { font-size: 18px; font-weight: 600; margin-bottom: 20px; color: #606266; display: flex; align-items: center; } .card-title i { margin-right: 8px; font-size: 20px; color: #409eff; } .input-group { margin-bottom: 20px; } .el-input { position: relative; font-size: 14px; display: inline-block; width: 100%; } .el-input__inner { -webkit-appearance: none; background-color: #fff; background-image: none; border-radius: 4px; border: 1px solid #dcdfe6; color: #606266; display: inline-block; font-size: inherit; height: 40px; line-height: 40px; outline: none; padding: 0 15px; transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1); width: 100%; } .el-input__inner:focus { border-color: #409eff; } .button-group { display: flex; gap: 12px; } .el-button { display: inline-flex; justify-content: center; align-items: center; line-height: 1; height: 40px; white-space: nowrap; cursor: pointer; background: #fff; border: 1px solid #dcdfe6; color: #606266; -webkit-appearance: none; text-align: center; box-sizing: border-box; outline: none; margin: 0; transition: .1s; font-weight: 500; padding: 12px 20px; font-size: 14px; border-radius: 4px; flex: 1; } .el-button--primary { color: #fff; background-color: #409eff; border-color: #409eff; } .el-button--primary:hover { background: #66b1ff; border-color: #66b1ff; } .el-button--success { color: #fff; background-color: #67c23a; border-color: #67c23a; } .el-button--success:hover { background: #85ce61; border-color: #85ce61; } .records-card { background: #fff; border-radius: 8px; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); padding: 25px; } table { width: 100%; border-collapse: collapse; margin-top: 20px; } th { background-color: #fafafa; color: #909399; font-weight: 600; text-align: left; padding: 12px 15px; border-bottom: 1px solid #ebeef5; } td { padding: 12px 15px; border-bottom: 1px solid #ebeef5; color: #606266; } tr:hover td { background-color: #f5f7fa; } .el-tag { display: inline-block; height: 32px; line-height: 30px; font-size: 12px; border-radius: 4px; box-sizing: border-box; white-space: nowrap; padding: 0 10px; } .el-tag--primary { color: #409eff; background-color: #ecf5ff; border-color: #d9ecff; } .el-tag--success { color: #67c23a; background-color: #f0f9eb; border-color: #e1f3d8; } .status-indicator { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; } .status-in { background-color: #409eff; } .status-out { background-color: #67c23a; } .empty-message { text-align: center; padding: 40px 0; color: #909399; } .empty-message i { font-size: 60px; color: #c0c4cc; margin-bottom: 20px; display: block; } .clock-time { font-size: 36px; font-weight: bold; text-align: center; color: #409eff; margin: 15px 0; font-family: 'Courier New', monospace; } .date-display { text-align: center; color: #909399; margin-bottom: 20px; } .name-display { margin: 20px 0 10px; font-size: 2.2rem; font-weight: 600; letter-spacing: 2px; font-family: 'Helvetica Neue', Arial, sans-serif; } .first-name { color: #303133; position: relative; } footer { text-align: center; margin-top: 40px; color: #909399; font-size: 14px; } @media (max-width: 768px) { .dashboard { flex-direction: column; } } </style> </head> <body> <div class="container"> <header> <h1>企业员工打卡系统</h1> <div class="date-display" id="currentDate"></div> <div class="clock-time" id="currentTime"></div> </header> <div class="dashboard"> <div class="clock-card"> <div class="card-title"> <span>员工打卡</span> </div> <div class="input-group"> <div class="el-input"> <input type="text" class="el-input__inner" id="employeeName" placeholder="请输入您的姓名"> </div> </div> <!-- <div class="name-display">--> <!-- <span id="employeeName" class="first-name"></span>--> <!-- </div>--> <div class="button-group"> <button class="el-button el-button--primary" id="clockInBtn">上班打卡</button> <button class="el-button el-button--success" id="clockOutBtn">下班签退</button> </div> </div> <div class="clock-card"> <div class="card-title"> <span>今日打卡状态</span> </div> <div id="todayStatus" class="empty-message"> <div>暂无今日打卡记录</div> </div> </div> </div> <div class="records-card"> <div class="card-title"> <span>打卡记录</span> </div> <div id="recordsTable"> <table> <thead> <tr> <th>员工姓名</th> <th>打卡时间</th> <th>打卡类型</th> </tr> </thead> <tbody id="recordsBody"> <!-- 记录将通过JS动态添加 --> </tbody> </table> <div id="emptyMessage" class="empty-message"> <div>暂无打卡记录</div> </div> </div> </div> <footer> <p>企业员工打卡系统 © 2023</p> </footer> </div> <script> // 模拟API请求的URL const API_BASE_URL = 'http://localhost:8080/api/clock'; // DOM元素 const employeeNameInput = document.getElementById('employeeName'); const clockInBtn = document.getElementById('clockInBtn'); const clockOutBtn = document.getElementById('clockOutBtn'); const recordsBody = document.getElementById('recordsBody'); const emptyMessage = document.getElementById('emptyMessage'); const todayStatus = document.getElementById('todayStatus'); const currentDate = document.getElementById('currentDate'); const currentTime = document.getElementById('currentTime'); // 初始化函数 function init() { // 设置当前日期和时间 updateDateTime(); setInterval(updateDateTime, 1000); // 绑定按钮事件 clockInBtn.addEventListener('click', () => clock('IN')); clockOutBtn.addEventListener('click', () => clock('OUT')); // 获取url地址参数 const dqurl = new URL(window.location.href); const dqparams = new URLSearchParams(dqurl.search); const dquserName = dqparams.get('userName'); document.getElementById('employeeName').textContent = dquserName; // 加载打卡记录 loadRecords(); } // 更新日期和时间 function updateDateTime() { const now = new Date(); currentDate.textContent = now.toLocaleDateString('zh-CN', { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' }); currentTime.textContent = now.toLocaleTimeString('zh-CN'); } // 打卡函数 function clock(type) { // const name = employeeNameInput.value.trim(); const name = employeeNameInput.textContent; if (!name) { alert('请重新登录'); return; } // 模拟API请求 const endpoint = type === 'IN' ? 'in' : 'out'; const url = `${API_BASE_URL}/${endpoint}?name=${encodeURIComponent(name)}`; // 显示加载状态 const originalText = type === 'IN' ? clockInBtn.textContent : clockOutBtn.textContent; const button = type === 'IN' ? clockInBtn : clockOutBtn; button.textContent = '处理中...'; button.disabled = true; // 模拟API请求延迟 setTimeout(() => { // 创建打卡记录对象 const record = { id: Date.now(), employeeName: name, clockTime: new Date().toISOString(), clockType: type }; // 添加到本地存储 saveRecord(record); // 更新UI addRecordToTable(record); updateTodayStatus(); // 显示成功消息 alert(type === 'IN' ? `${name} 上班打卡成功!` : `${name} 下班签退成功!`); // 恢复按钮状态 button.textContent = originalText; button.disabled = false; // 清空输入框 employeeNameInput.value = ''; }, 800); } 保存记录到本地存储 function saveRecord(record) { const records = JSON.parse(localStorage.getItem('clockRecords') || '[]'); records.unshift(record); localStorage.setItem('clockRecords', JSON.stringify(records)); } // 从本地存储加载记录 function loadRecords() { const records = JSON.parse(localStorage.getItem('clockRecords') || '[]'); if (records.length === 0) { emptyMessage.style.display = 'block'; recordsBody.innerHTML = ''; } else { emptyMessage.style.display = 'none'; recordsBody.innerHTML = ''; records.forEach(record => { addRecordToTable(record); }); } updateTodayStatus(); } // 添加记录到表格 function addRecordToTable(record) { const row = document.createElement('tr'); // 格式化日期时间 const clockTime = new Date(record.clockTime); const formattedTime = clockTime.toLocaleString('zh-CN'); // 创建行内容 row.innerHTML = ` <td>${record.employeeName}</td> <td>${formattedTime}</td> <td> <span class="el-tag ${record.clockType === 'IN' ? 'el-tag--primary' : 'el-tag--success'}"> ${record.clockType === 'IN' ? '上班打卡' : '下班签退'} </span> </td> `; recordsBody.prepend(row); emptyMessage.style.display = 'none'; } // 更新今日打卡状态 function updateTodayStatus() { const records = JSON.parse(localStorage.getItem('clockRecords') || '[]'); const today = new Date().toDateString(); // 筛选今日记录 const todayRecords = records.filter(record => { const recordDate = new Date(record.clockTime).toDateString(); return recordDate === today; }); if (todayRecords.length === 0) { todayStatus.innerHTML = '<div>暂无今日打卡记录</div>'; return; } // 按时间排序 todayRecords.sort((a, b) => new Date(a.clockTime) - new Date(b.clockTime)); // 生成状态HTML let statusHtml = ''; todayRecords.forEach(record => { const time = new Date(record.clockTime).toLocaleTimeString('zh-CN'); statusHtml += ` <div class="status-item"> <span class="status-indicator ${record.clockType === 'IN' ? 'status-in' : 'status-out'}"></span> <span>${time} - ${record.clockType === 'IN' ? '上班打卡' : '下班签退'}</span> </div> `; }); todayStatus.innerHTML = statusHtml; } // 页面加载完成后初始化 document.addEventListener('DOMContentLoaded', init); </script> </body> </html> 将上诉的写成调用接口的方式,不存储在本地
08-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值