資源描述:
《經(jīng)典C語言源代碼 最新最全.docx》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、優(yōu)質(zhì)文檔經(jīng)典C語言源代碼1、(1)某年某月某日是星期幾#includeintmain(){intyear,month,day;while(scanf_s("%d%d%d",&year,&month,&day)!=EOF){if(month==1
2、
3、month==2)//判斷month是否為1或2 {year--;month+=12;}intc=year/100;inty=year-c*100;intweek=(c/4)-2*c+(y+y/4)+(13*(month+1)/5)+day-1;44優(yōu)質(zhì)文檔while(week<0){week+=7;}week%=7;switch
4、(week){case1:printf("Monday");break;case2:printf("Tuesday");break;case3:printf("Wednesday");break;case4:printf("Thursday");break;case5:printf("Friday");break;case6:printf("Saturday");break;case0:printf("Sunday");break;}}return0;}1、(2)某年某月某日是第幾天(一維數(shù)組)#include"stdio.h"44優(yōu)質(zhì)文檔voidmain(){i
5、nti,flag,year,month,day,dayth;intmonth_day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};printf("請輸入年/月/日:");scanf_s("%d/%d/%d",&year,&month,&day);dayth=day;flag=(year%400==0)
6、
7、(year%4==0&&year%100!=0);if(flag)month_day[2]=29;for(i=1;i8、month,day,dayth);}2、30個數(shù)中找最小的數(shù)及其位置#include"stdio.h"#defineSIZE3044優(yōu)質(zhì)文檔voidmain(){inti;floatdata[SIZE];intmin;printf("請輸入%d個浮點數(shù):",SIZE);for(i=0;i9、是%5d",data[min],min);}44優(yōu)質(zhì)文檔3、30個數(shù)從小到大排序(1)#include"stdio.h"#defineSIZE30voidmain(){inti,j;floatdata[SIZE],temp;intmin;printf("請輸入%d個整型數(shù):",SIZE);for(i=0;i10、ata[i];data[i]=temp;}printf("排序后的結(jié)果是:");for(i=0;i11、序前:");show_array(score,SIZE);sort(score,SIZE);printf("排序后:");show_array(score,SIZE);}voidaccept_array(floata[],intsize){inti;printf("請輸入%d個分?jǐn)?shù):",size);for(i=0;i