简单易懂的C语言源代码供初学者使用Word下载.docx
《简单易懂的C语言源代码供初学者使用Word下载.docx》由会员分享,可在线阅读,更多相关《简单易懂的C语言源代码供初学者使用Word下载.docx(10页珍藏版)》请在冰豆网上搜索。
{printf("
error!
!
nbushijishu!
n);
return;
/*n在这里不能是奇数*/
x=(4*m-n)/2;
y=(n-2*m)/2;
if((x>
=0)&
&
(y>
=0))
printf("
x=%d,y=%d\n"
x,y);
else
shurucuowu!
getch();
math.h>
stdlib.h>
{floata,b,C;
enter3number(a,b,C):
%.2f%.2f%.2f"
a,&
b,&
C);
s=0.5*a*b*sinC;
s=%.2f\n"
s);
{intds,nl,yf;
charc;
shuruds;
%d"
ds);
if(ds<
14||ds>
1184)
inputerror!
pressanyend...\n"
%c"
c);
exit(0);
/*输入的数字必须是-14~1184之间*/
nl=(ds+115)%100;
yf=(ds+115)/100;
nl=%d,yf=%d\n"
nl,yf);
string.h>
{chars1[100],s2[100],s3[100],s4[100];
inputastring:
gets(s1);
strcpy(s1,s2);
strcat(s1,"
--------------"
strcpy(s3,strcat(s1,"
));
strcat(strcpy(s3,strcat(s1,"
)),s2);
strcpy(s4,strcat(strcpy(s3,strcat(s1,"
)),s2));
puts(s4);
pasue"
{floatx1,x2,a,b,c;
input3number(a,b,c):
%f%f%f"
x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
x1=%f,X2=%f\n"
x1,x2);
{inta,b,c,t;
input3number:
%d%d%d"
if(a>
b)
{t=a;
a=b,b=t;
c)
a=c;
c=t;
if(b>
{t=b;
b=c;
1:
%d,2:
%d,3:
%d\n"
a,b,c);
conio.h>
textbackground(YELLOW);
/*设置背景色为黄色,注意颜色应该大写,可更改*/
textcolor(RED);
/*设置文件颜色为红色,可更改*/
clrscr();
/*清屏,使设置生效*/
"
if(r<
0)
EnterError!
/*暂停,按任一键继续*/
{floata,b,c,delt,x1,x2,p,q;
textcolor(YELLOW);
Inputabc:
if(a==0)
It'
snotaquadraticequation!
delt=b*b-4*a*c;
if(delt>
=0)
{x1=(-b+sqrt(delt))/(2*a);
x2=(-b-sqrt(delt))/(2*a);
x1=%.3fx2=%.4f\n"
{p=-b/(2*a);
q=sqrt(-delt)/(2*a);
p=%.4fq=%.4f\n"
p,q);
intk=0;
while(k<
=3){
pressanykeytocontinue\npressesctoexit."
k++;
time.h>
{inta,b,c,oper;
longlimit,i=0;
charchar1;
textcolor(GREEN);
/*设置字体颜色为绿色*/
/*清屏,是设置生效*/
while(i<
=3)
qingxuanzejiahuojian(1or2,1:
+,2:
-\n"
oper);
Entermax(<
10000):
%ld"
limit);
srand((unsignedlong)time(0));
a=rand()*limit/RAND_MAX;
b=rand()*limit/RAND_MAX;
while((a<
b)&
(oper==2))
{a=rand()*limit/RAND_MAX;
char1=(oper==2?
'
-'
:
+'
%d%c%d\n"
a,char1,b);
if((oper==2&
a-b==c)||(oper!
=2&
a+b==c))
OK!
Youareveryclever!
Theresultisnotcorrect!
i++;
{inty,i=0;
/*天下事无难易之分只有做与不做之别*/
textbackground(GREEN);
/*清屏,是设置生效*/
Inputyear:
y);
if(y%4==0)
{if(y%100==0)
{if(y%400==0)
yshirunnian!
ybushirunnian!
ybushirunnian!
getche();
main()
{
intxz,wday1,hour1;
structtm*timeptr;
time_tsecsnow;
chars1[30],s2[30],s3[30];
inputwhomdoyousayto?
xz);
if(xz==1)
strcpy(s1,"
mother"
elseif(xz==2)
father"
else
time(&
secsnow);
timeptr=localtime(&
wday1=timeptr->
tm_wday;
if(wday1==6)
strcpy(s2,"
Happysaturday!
elseif(wday1==0)
Happysunday"
hour1=timeptr->
tm_hour;
if(hour1>
=4&
hour1<
=10)
strcpy(s3,"
Goodmorning!
elseif(hour1>
=17&
=22)
Goodafternoon!
Goodevening!
%s%s%s"
s1,s2,s3);
}
{intday,year,month,i=0;
textbackground(BROWN);
=3)
Input2number:
year,&
month);
switch(month)
{case1:
case3:
case5:
case7:
case8:
case10:
case12:
day=31;
break;
case4:
case6:
case11:
day=30;
case2:
day=28;
if((year%4==0&
year%100!
=0)||year%400==0)
day=29;
deflault:
Invalidmonthinput!
Thereare%ddaysin%d.%d\n"
day,year,month);