c語言日曆顏色,c語言顏色代碼表

本文目錄一覽:

用C語言編寫一個日曆

# include stdio.h

# include math.h

void printmonth(int m);

void printhead(int m);

int daysofmonth(int m);

int firstday(int y);

int year,weekday;

void main()

{

int i;

printf(“請輸入年份:”);

scanf(“%d”, year);

weekday=firstday(year);

printf(“\n\n”);

printf(” %d年\n”,year);

for(i=1;i=12;i++)

{

printmonth(i);

printf(“\n”);

}

printf(“\n\n”);

}

void printmonth(int m) //打印每月日曆

{

int i,days;

printhead(m);

days=daysofmonth(m);

for(i=1;i=days;i++)

{

printf(“%5d”,i);

weekday=(weekday+1)%7;

if (weekday==0) printf(“\n “);

}

}

void printhead(int m) //打印每月的日曆頭(判定起始位置)

{

int i;

printf(“\n%d月 日 一 二 三 四 五 六\n”,m);

printf(” “);

for(i=0;iweekday;i++)

printf(” “);

}

int daysofmonth(int m) //每月的天數

{

switch (m)

{

case 1:

case 3:

case 5:

case 7:

case 8:

case 10:

case 12:return 31;

case 4:

case 6:

case 9:

case 11:return 30;

case 2:if (((year%4==0 year%100!=0)||year%400==0))

return 29;

else

return 28;

default: return 0;

}

}

int firstday(int y) //判斷某年元旦是星期幾

{

double s ;

s=floor(year-1+(year-1)/4.0-(year-1)/100.0+(year-1)/400.0+1);

return (int)s%7;

}

C語言編寫日曆

#include stdio.h

int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

void print_calendar(int y);

void main()

{

int y;

printf(“Calendar system :\n”);

printf(“Please input a year between 1600 2500:”);

while(scanf(“%d”,y)!=EOF)//輸入年份

{

if (y1600 || y2500)

{

printf(“Invalid input. Please try again!\n”);

printf(“Please input a year between 1600 2500:”);

continue;

}

print_calendar(y);

}

}

void print_calendar(int y) //打印日曆

{

int i,sum,days,k,m;

char monthname[12][20] = {“January”,”February”,”March”,”April”,”May”,”June”,”July”,”August”,”September”,”October”,”November”,”December”};

if((0==y%4y%100!=0)||0==y%400 ) //閏年判斷

month[2]=29;

for(m=1;m13;m++)

{

days = 0;

for (i=1;im;i++) //計算m月1號是第幾天

days+=month[i];

days++;

sum=y-1+(y-1)/4-(y-1)/100+(y-1)/400+days;

k=sum%7; //k是星期幾,k=0星期日

printf(“%s %d\n”,monthname[m-1],y);

printf(” S M Tu W Th F S\n”);

printf(“%*d”,3*(k+1)-1,1);//先輸出3*(k+1)-1個空格,在輸出1

k++;

for(i=2;i=month[m];i++)

{

if(k == 7)

{

printf(“\n”);

k=0;

}

if (k == 0)

printf(“%2d”,i);

else

printf(“%3d”,i);

k++;

}

printf(“\n\n”);

}

}

C語言萬年曆我想把輸出的日曆調到屏幕中間,把字體的顏色換位紅色怎麼弄?求助

initgraph(gdriver,gmode,”c:\\tc”);

cleardevice();

setbkcolor(9);

這裡不是有設置背景色的接口嗎?

不知道LZ編譯的是什麼工程,代碼不全也。

C語言怎麼調顏色??

第一步、進入到vs界面,在上方工具欄中選擇箭頭所指的工具選項,如下圖所示。

第二步、選擇箭頭所指的選項,點擊進入選項窗口,如下圖所示。

第三步、點擊箭頭所指的環境選項,進入到環境設置,如下圖所示。

第四步、在下拉列表中選擇箭頭所指的字體和顏色,進行相關設置,如下圖所示。

第五步、在這裡可以對各種顯示項的格式進行相關的設置,包括大小,字體,像前景,項背景等,可以進行自己喜歡的設置,如下圖所示。

求C語言顏色代碼大全,謝謝!

已經按你的要求重新改寫,簡化。

本題一個完整的c程序如下,程序在tc2.0和win-tc下運行通過,結果正確。

#includestdio.h

#includestdlib.h

#includeconio.h

main()

{float pi=3.14159265,r;

textbackground(YELLOW);/* 設置背景色為黃色,注意顏色應該大寫,可更改 */

textcolor(RED); /* 設置文件顏色為紅色,可更改 */

clrscr(); /* 清屏,使設置生效 */

printf(“enter radius:”);

scanf(“%f”,r);

if(r0)

printf(“Enter Error!\n”);

else

printf(“r=%.2f,c=%.2f,area=%.2f\n”,r,2*pi*r,pi*r*r);

system(“pause”);/* 暫停,按任一鍵繼續 */

}

———————————————————————

———————————————————————

以下僅供參考。可以連續輸入8次,每次得到的顏色不同,當然可以改變for (color = 0; color 8; color++)中color8的數值來控制輸出的顏色數。

#includestdio.h

#includestdlib.h

#includeconio.h

#includegraphics.h

main()

{float pi=3.14159265,r;

int color;

for (color = 0; color 8; color++)

{

textbackground(color);

cprintf(“This is color %d\r\n”, color);

cprintf(“enter radius:”);

scanf(“%f”,r);

if(r0)

cprintf(“Enter Error!\r\n”);

else

cprintf(“r=%.2f,c=%.2f,area=%.2f\r\n”,r,2*pi*r,pi*r*r);

cprintf(“Press any key to continue\r\n”);

getch();

}

system(“pause”);

}

你可以參閱:

c語言日曆

..肯定編譯出錯了,要不就是你的常數錯誤,仔細檢查下代碼,如果不行換個編譯器看看,甚至換台機器看下

原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/200131.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
小藍的頭像小藍
上一篇 2024-12-05 14:03
下一篇 2024-12-05 14:03

相關推薦

  • AES加密解密算法的C語言實現

    AES(Advanced Encryption Standard)是一種對稱加密算法,可用於對數據進行加密和解密。在本篇文章中,我們將介紹C語言中如何實現AES算法,並對實現過程進…

    編程 2025-04-29
  • 學習Python對學習C語言有幫助嗎?

    Python和C語言是兩種非常受歡迎的編程語言,在程序開發中都扮演着非常重要的角色。那麼,學習Python對學習C語言有幫助嗎?答案是肯定的。在本文中,我們將從多個角度探討Pyth…

    編程 2025-04-29
  • Python被稱為膠水語言

    Python作為一種跨平台的解釋性高級語言,最大的特點是被稱為”膠水語言”。 一、簡單易學 Python的語法簡單易學,更加人性化,這使得它成為了初學者的入…

    編程 2025-04-29
  • OpenJudge答案1.6的C語言實現

    本文將從多個方面詳細闡述OpenJudge答案1.6在C語言中的實現方法,幫助初學者更好地學習和理解。 一、需求概述 OpenJudge答案1.6的要求是,輸入兩個整數a和b,輸出…

    編程 2025-04-29
  • Python按位運算符和C語言

    本文將從多個方面詳細闡述Python按位運算符和C語言的相關內容,並給出相應的代碼示例。 一、概述 Python是一種動態的、面向對象的編程語言,其按位運算符是用於按位操作的運算符…

    編程 2025-04-29
  • Python語言由荷蘭人為中心的全能編程開發工程師

    Python語言是一種高級語言,很多編程開發工程師都喜歡使用Python語言進行開發。Python語言的創始人是荷蘭人Guido van Rossum,他在1989年聖誕節期間開始…

    編程 2025-04-28
  • Python語言設計基礎第2版PDF

    Python語言設計基礎第2版PDF是一本介紹Python編程語言的經典教材。本篇文章將從多個方面對該教材進行詳細的闡述和介紹。 一、基礎知識 本教材中介紹了Python編程語言的…

    編程 2025-04-28
  • Python設置print顏色

    無論是在學習Python語言還是在實際開發中,輸出結果都是非常關鍵的部分。Python內置的print()函數是最常用的輸出方法之一,而如何設置輸出結果的顏色,則是開發人員經常遇到…

    編程 2025-04-28
  • Python語言實現人名最多數統計

    本文將從幾個方面詳細介紹Python語言實現人名最多數統計的方法和應用。 一、Python實現人名最多數統計的基礎 1、首先,我們需要了解Python語言的一些基礎知識,如列表、字…

    編程 2025-04-28
  • Python作為中心語言,在編程中取代C語言的優勢和挑戰

    Python一直以其簡單易懂的語法和高效的編碼環境而著名。然而,它最近的發展趨勢表明Python的使用範圍已經從腳本語言擴展到了從Web應用到機器學習等廣泛的開發領域。與此同時,C…

    編程 2025-04-28

發表回復

登錄後才能評論