实验二
#include <stdio.h>
int main()
{
char a,b,c,d,e;
printf("请输入五个字符:\n");
a=getchar();
b=getchar();
c=getchar();
d=getchar();
e=getchar();
putchar(a);
putchar(b);
putchar(c);
putchar(d);
putchar(e);
putchar('\n');
return 0;
}
#include <stdio.h>
void main()
{
int year,a;
printf("请输入年份:");
scanf("%d",&year);
if((year%4==0&&year%100!=0)||(year%400==0)) a=1;
else a=0;
if (a==1)
printf("\n%d年的二月份有29天\n",year);
else printf("%d年的二月有28天\n",year);
}
void main()
{
int year,a;
printf("请输入年份:");
scanf("%d",&year);
if((year%4==0&&year%100!=0)||(year%400==0)) a=1;
else a=0;
if (a==1)
printf("\n%d年的二月份有29天\n",year);
else printf("%d年的二月有28天\n",year);
}
![](https://img2018.cnblogs.com/blog/1621661/201906/1621661-20190620154651010-2066905410.png)
![](https://img2018.cnblogs.com/blog/1621661/201906/1621661-20190620154759942-1293877997.png)
#include <stdio.h>
int main(void)
{
int a,b,c,temp;
printf("请输入三角形三边的长:");
scanf("%d%d%d",&a,&b,&c);
if(a<b)
{
temp=a;
a=b;
b=temp;
}
if(a<c)
{
temp=a;
a=c;
c=temp;
}
if(b<c)
{
temp=b;
b=c;
c=temp;
}
if(a<=0||b<=0||c<=0||b+c<=a)
{
printf("该三角形不成立\n");
return 0;
}
if (a==b&&b==c)
{
printf("该三角形是等边三角形\n");
return 0;
}
if((a==b||b==c))
{
printf("该三角形是等腰三角形\n");
return 0;
}
if(a*a==b*b+c*c)
{
printf("该三角形是直角三角形\n");
return 0;
}
printf("该三角形是一般三角形\n");
return 0;
}
int main(void)
{
int a,b,c,temp;
printf("请输入三角形三边的长:");
scanf("%d%d%d",&a,&b,&c);
if(a<b)
{
temp=a;
a=b;
b=temp;
}
if(a<c)
{
temp=a;
a=c;
c=temp;
}
if(b<c)
{
temp=b;
b=c;
c=temp;
}
if(a<=0||b<=0||c<=0||b+c<=a)
{
printf("该三角形不成立\n");
return 0;
}
if (a==b&&b==c)
{
printf("该三角形是等边三角形\n");
return 0;
}
if((a==b||b==c))
{
printf("该三角形是等腰三角形\n");
return 0;
}
if(a*a==b*b+c*c)
{
printf("该三角形是直角三角形\n");
return 0;
}
printf("该三角形是一般三角形\n");
return 0;
}
![](https://img2018.cnblogs.com/blog/1621661/201906/1621661-20190620154819377-142516592.png)
![](https://img2018.cnblogs.com/blog/1621661/201906/1621661-20190620154827944-23866673.png)
![](https://img2018.cnblogs.com/blog/1621661/201906/1621661-20190620154837419-282775875.png)