zoukankan      html  css  js  c++  java
  • 显示一个月的提醒日期

     1 #include "stdafx.h"
     2 #include <stdio.h>
     3 #include <stdlib.h>
     4 #include <string.h>
     5 #define MAX_REMIND 50
     6 #define MSG_LEN 60
     7 int read_line(char str[],int n);
     8 int main(void)
     9 {
    10     char reminders[MAX_REMIND][MSG_LEN+3];
    11     char day_str[3],msg_str[MSG_LEN+1];
    12     int day,i,j,num_remind =0;
    13 
    14     for(;;)
    15     {
    16         if(num_remind == MAX_REMIND)
    17         {   
    18             printf_s("-- NO space left--
    ");
    19             break;
    20         }
    21         printf_s("Enter day and reminder:");
    22         scanf_s("%2d",&day);
    23         if(day == 0)
    24             break;
    25         sprintf(day_str,"%2d",day);
    26         read_line(msg_str,MSG_LEN);
    27         for(i = 0;i < num_remind;i++)
    28             if((strcmp(day_str,reminders[i])) < 0)
    29                 break;
    30         for(j = num_remind ; j > i ; j--)
    31             strcpy_s(reminders[j],reminders[j-1]);
    32         strcpy_s(reminders[i],day_str);
    33         strcat_s(reminders[i],msg_str);
    34         num_remind++;
    35     }
    36     printf_s("
    Day Reminder
    ");
    37     for(i = 0;i < num_remind;i++)
    38     {
    39         printf_s("%s
    ",reminders[i]);
    40     }
    41     system("pause");
    42     return 0;
    43 }
    44 int read_line(char str[],int n)
    45 {
    46     int ch , i = 0;
    47     while((ch = getchar() != '
    '))
    48     {
    49         if(i < n)
    50         {
    51             str[i++] = ch;
    52         }
    53     }
    54  str[i] = '';
    55  return i;
    56 }
    57     
  • 相关阅读:
    数据库设计
    Android入门
    Java
    深入理解计算机
    Python
    JS
    powerdesigner
    计算机程序员+研一生活总结
    影视剧里程序员使用的双显示屏,在生活中真的需要么?
    性质太恶劣,紧张时期竟有人开发假冒健康码软件,幸已下架!
  • 原文地址:https://www.cnblogs.com/joyclub/p/4425136.html
Copyright © 2011-2022 走看看