程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> C說話完成的法式員老皇歷實例

C說話完成的法式員老皇歷實例

編輯:關於C++

C說話完成的法式員老皇歷實例。本站提示廣大學習愛好者:(C說話完成的法式員老皇歷實例)文章只能為提供參考,不一定能成為您想要的結果。以下是C說話完成的法式員老皇歷實例正文


本文實例講述了C說話完成的法式員老皇歷。分享給年夜家供年夜家參考。詳細以下:

之前看到過一個jquery法式員老皇歷頁面,認為挺有創意的,本身閒著用C說話也寫了一個,根本就是隨機數的生成,沒甚麼難度,年夜家隨意看看,高手請繞過此篇,掌握台法式沒甚麼雅觀可言,曾經盡可能弄得悅目點了。

#include <stdio.h>
#include <time.h>
int random(int dayseed,int indexseed)
//依據以後時光“天 ”發生偽隨機數。 
{
  int i,n;
  n = dayseed % 11117;
  for (i = 0; i < 100 + indexseed; i++) 
  {
    n = n * n;
    n = n % 11117;  // 11117 是個質數
  }
  return n;
}
int isWeekend(struct tm *p) 
{
  return p->tm_wday == 0 || p->tm_wday == 6;
}  
int main(int argc, char *argv[])
{
  char *weeks[6] = {"一","二","三","四","五","六","日"};
  printf("|-------------------------------------|\n");
  printf("|     法式員老皇歷beta 1.0    |\n");
  printf("|-------------------------------------|\n");
  time_t timep; 
  struct tm *p; 
  time(&timep); 
  p =localtime(&timep);
  //此函數取得的tm構造體的時光,是曾經停止過時區轉化為當地時光  
  printf("|-------------------------------------|\n");
  printf("|   明天是%d年%d月%d日 禮拜%s   |\n",1900+p->tm_year,1+p->tm_mon,p->tm_mday,weeks[p->tm_wday-1]); 
  printf("|-------------------------------------|\n");
  int randNum=random(p->tm_mday, 2);//發生偽隨機數
  int randNum1=random(p->tm_mday, 3);
  char *activities[27][3] = { 
  {"寫單位測試", "寫單位測試將削減失足","寫單位測試會下降你的開辟效力"},
  {"日間上線", "明天日間上線是平安的","能夠招致災害性效果"},
  {"重構", "代碼質量獲得進步","你很有能夠會墮入泥潭"},
  {"應用%t", "你看起來更有檔次","他人會認為你在裝逼"},
  {"跳槽", "該撒手時就撒手","鑒於以後的經濟情勢,你的下一份任務未必比如今強"},
  {"招人", "你碰到千裡馬的能夠性年夜年夜增長","你只會招到一兩個混飯吃的內行"},
  {"面試", "面試官明天心境很好","面試官不爽,會拿你出氣"},
  {"提交告退請求", "公司找到了一個比你更無能更廉價的家伙,恨不得你趕緊滾開","鑒於以後的經濟情勢,你的下一份任務未必比如今強"},
  {"請求加薪", "老板明天心境很好","公司正在斟酌裁人"},
  {"早晨加班", "早晨是法式員精力最好的時刻","", },
  {"定名變量\"%v\"", "",""},
  {"寫跨越%l行的辦法", "你的代碼組織的很好,長一點沒緊要","你的代碼將凌亂不勝,你本身都看不懂"},
  {"提交卸碼", "碰到抵觸的概率是最低的","你碰到的一年夜堆抵觸會讓你認為本身是否是時光穿越了"},
  {"代碼復審", "發明主要成績的概率年夜年夜增長","你甚麼成績都發明不了,白白糟蹋時光"},
  {"閉會", "寫代碼之余抓緊一下打個盹,無益安康","你會被扣屎盆子背黑鍋"},
  {"早晨上線", "早晨是法式員精力最好的時刻","你日間曾經精疲力竭了"},
  {"修復BUG", "你明天對BUG的嗅覺年夜年夜進步","新發生的BUG將比修復的更多"},
  {"設計評審", "設計評審會議將釀成腦筋風暴","人人精疲力竭,評審就這麼過了"},
  {"需求評審", "",""},
  {"打DOTA", "你將有如神助","你會被虐的很慘", },      //這裡往下的是周末特定情形 (19-27)
  {"洗澡", "你幾天沒洗澡了?","會把設計方面的靈感洗失落", },
  {"錘煉一下身材", "","能量沒消費若干,吃得卻更多", },
  {"吸煙", "吸煙有益於提神,增長思想迅速","除非你活夠了,逝世得早點沒緊要", },
  {"在妹子眼前吹法螺", "改良你矮窮挫的抽象","會被識破", },
  {"撸管", "防止緩沖區溢出","強撸灰飛煙滅", },
  {"閱讀成人網站", "重拾對生涯的信念","你會意神不寧", },
  {"上微博", "明天產生的事不克不及錯過","會看到使人心境欠好的事", },
  {"上AB站", "還須要來由嗎?","滿屏的兄貴我會說出來?", }
};
  printf("|-------------------------------------|\n");
  if(isWeekend(p))  
  printf("| 宜: \n| %2s\n| %s\n",activities[19+randNum%8][0],activities[randNum%27][1]);
  else
  printf("| 宜: \n| %2s\n| %s\n",activities[randNum%17][0],activities[randNum%27][1]);
  printf("|-------------------------------------|\n");  
  printf("|-------------------------------------|\n");  
  if(isWeekend(p))
  printf("| 不宜:\n| %s\n| %s\n",activities[19+randNum1%8][0],activities[randNum1%27][2]);
  else
  printf("| 不宜:\n| %s\n| %s\n",activities[randNum1%17][0],activities[randNum1%27][2]);
  printf("|-------------------------------------|\n"); 
  /*坐位朝向*/  
  char *directions[8]= {"南方","西南方","西方","西北方","南邊","東北方","東方","東南方"};
  printf("|-------------------------------------|\n");
  printf("| 坐位朝向:面向 %s 寫法式,BUG 起碼.\n",directions[randNum%8]);
  /*昔日宜飲*/
  char *drinks[14] = {"水","茶","紅茶","綠茶","咖啡","奶茶","可樂","牛奶","豆奶","果汁","果味汽水","蘇取水","活動飲料","酸奶","酒"};  
  printf("|-------------------------------------|\n");
  printf("| 昔日宜飲:%s,%s\n",drinks[randNum%14],drinks[randNum1%14]);
  /*女神親近指數*/
  int ambiguous = randNum%10;
  printf("|-------------------------------------|\n");
  if(10==ambiguous)
  printf("| 親近指數為10,上吧,騷年!\n");
  else
  printf("| 女神親近指數:%d \n",ambiguous);
  printf("|-------------------------------------|\n");
  return 0;
}

運轉後果以下圖所示:

願望本文所述對年夜家的C說話法式設計有所贊助。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved