预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共34页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

经典C语言源代码1、(1)某年某月某日是星期几#include<stdio.h>intmain(){intyear,month,day;while(scanf_s("%d%d%d",&year,&month,&day)!=EOF){if(month==1||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;while(week<0){week+=7;}week%=7;switch(week){case1:printf("Monday\n");break;case2:printf("Tuesday\n");break;case3:printf("Wednesday\n");break;case4:printf("Thursday\n");break;case5:printf("Friday\n");break;case6:printf("Saturday\n");break;case0:printf("Sunday\n");break;}}return0;}1、(2)某年某月某日是第几天(一维数组)#include"stdio.h"voidmain(){inti,flag,year,month,day,dayth;intmonth_day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};printf("请输入年/月/日:\n");scanf_s("%d/%d/%d",&year,&month,&day);dayth=day;flag=(year%400==0)||(year%4==0&&year%100!=0);if(flag)month_day[2]=29;for(i=1;i<month;i++)dayth=dayth+month_day[i];printf("%d/%d/%d是第%d天\n",year,month,day,dayth);}2、30个数中找最小的数及其位置#include"stdio.h"#defineSIZE30voidmain(){inti;floatdata[SIZE];intmin;printf("请输入%d个浮点数:\n",SIZE);for(i=0;i<SIZE;i++){//scanf_s("%f",&data[i]);data[i]=rand()%30+1;printf("%f、",data[i]);}min=0;for(i=1;i<SIZE;i++){if(data[i]<data[min])min=i;}printf("最小值是%5.2f,位置是%5d\n",data[min],min);}3、30个数从小到大排序(1)#include"stdio.h"#defineSIZE30voidmain(){inti,j;floatdata[SIZE],temp;intmin;printf("请输入%d个整型数:\n",SIZE);for(i=0;i<SIZE;i++){scanf_s("%f",&data[i]);}for(i=0;i<SIZE;i++){min=i;for(j=i+1;j<SIZE;j++)if(data[j]<data[min])min=j;temp=data[min];data[min]=data[i];data[i]=temp;}printf("\n排序后的结果是:\n");for(i=0;i<SIZE;i++)printf("%5.2f",data[i]);}(2)模块化程序(数组名作为函数参数)#include"stdio.h"#defineSIZE5voidaccept_array(floata[],intsize);voidsort(floata[],intsize);voidshow_array(floata[],intsize);voidmain(){floatscore[SIZE];accept_array(score,SIZE);printf("排序前:");show_array(score,SIZE);sort(score,SIZE);printf("排序后:");show_array(score,SIZE);}voidaccept_array(floata[],intsize){inti;printf("请输入%d个分数:",size);for(i=0;i<size;i++)scanf_s("%f",&a[i]);}voidshow_array(floata[],intsize){inti;for(i=0;i<size;i++)