# 实验3

2021-01-04 14:37:19

``````#include<stdio.h>
int main()
{
char c;
printf("请输入字符：\n");
c = getchar();
if (c >= 65 && c <= 90)
{
c += 32;putchar(c);
}
else
{
putchar(c);
}
}
``````

``````#include<stdio.h>
int main()
{
int s, x;
printf("请输入x的值：");
scanf_s("%d", &x);
if (x >= 0 && x <= 8)
{
s = 2 * x * x + x + 10;
}
else
{
s = x - 3 * x * x * x - 9;
}
printf("计算结果 %d", s);
}
``````

``````#include<stdio.h>
int main()
{
int a, b;
printf("请输入成绩：\n");
scanf_s("%d", &a);
b = a/10;
switch (b)
{
case 10:
case 9:
printf("优秀");break;
case 8:
printf("良好");break;
case 7:
printf("中等");break;
case 6:
printf("及格");break;
default:
printf("不及格");
}
return 0;
}
``````

``````#include<stdio.h>
#include<math.h>
int main()
{
double a, b, c, x;
printf("请输入数字：");
scanf_s("%lf", &x);
a = sin(x) + log(x + 1) / log(2.718);
b = pow(2.718, x) + abs(cos(x));
c = a / b;
printf("输入为：%lf", c);
return 0;
}
``````

``````#include<stdio.h>
#include<math.h>
int main()
{
int a, b, c, d, e=0;
for (a = 100;a < 1000;a++)
{
b = a / 100;
c = a / 10 - b * 10;
d = a % 10;
if (a == pow(b, 3) + pow(c, 3) + pow(d, 3))
{
printf("%d\n", a);
e = e + 1;
}
}
printf("以上都是水仙花数，共%d个", e);
return 0;
}
``````

``````#include<stdio.h>
#include<math.h>
int main()
{
double a, b, c, d;
printf("请输入数字:\n");
scanf_s("%lf", &a);
b = 0;
c = 1;
for (c;c <= a;c++)
{
for (d=1;d <= c;d++)
{
b += pow(10, d - 1) * a;
}
}
printf("%2.lf", b);
return 0;
}
``````

``````#include<stdio.h>
int main()
{
for (int i = 1;i < 5;i++)
{
for (int j = 0;j < 5 - i;j++)
{
printf(" ");
}
for (int k=1;k <= 5;k++)
{
printf("*");
}
printf("\n");
}
return 0;
}
``````

``````#include<stdio.h>
int main()
{
for (int i = 0;i < 7;i++)
{
for (int j = 0;j < 7 - i;j++)
{
printf(" ");
}
for (int k=1;k <= i*2+1;k++)
{
printf("*");
}
printf("\n");
}
return 0;
}
``````

``````#include<stdio.h>
int main()
{
for (int i = 0;i < 7;i++)
{
for (int j = 0;j < 7 - i;j++)
{
printf(" ");
}
for (int k=1;k <= i*2+1;k++)
{
printf("*");
}
printf("\n");
}
for (int i = 0;i < 7;i++)
{
for (int j = 0;j < i+2;j++)
{
printf(" ");
}
for(int k=1;k<=11-2*i;k++)
{
printf("*");
}
printf("\n");
}
return 0;
}
``````

``````#include<stdio.h>
int main()
{
char a, b;
for (int i = 0;i < 7;i++)
{
for (int j = 0;j < 7 - i;j++)
{
a = 65 + i;
printf(" ");
}
for (int k = 1;k <= i * 2 + 1;k++)
{
printf("%c",a);
}
printf("\n");
}
for (int i = 0;i < 7;i++)
{
for (int j = 0;j < i + 2;j++)
{
b = 70 - i;
printf(" ");
}
for (int k = 1;k <= 11 - 2 * i;k++)
{
printf("%c",b);
}
printf("\n");
}
return 0;
}
``````

``````#include<stdio.h>
int main()
{
long num, i, count = 0;
scanf_s("%d", &num);
printf("从低到高:\n");
printf("%d\n", num % 10);
for (i = 1;num /= 10;i++)
{
printf("%d\n", num % 10);
}
printf("共有%d位数", i);
return 0;
}
``````

``````include<stdio.h>
int main()
{
int d1, d2, d3, e1, e2, e3, t = 0;
printf("输入第一个日期 如2021/1/4:");
scanf_s("%d/%d/%d", &d1, &d2, &d3);
printf("输入第二个日期 如2021/1/8:");
scanf_s("%d/%d/%d", &e1, &e2, &e3);
if (d1 > e1)
t = 0;
else if (d1 == e1)
{
if (d2 > e2)
t = 0;
else if (d2 = e2)
{
if (d3 > e3)
t = 0;
else if (d3 = e3)
printf("same data");
}
}
else t = 1;
switch (t)
{
case 1:printf("%d/%d/%d比%d/%d/%d早", d1, d2, d3, e1, e2, e3);break;
case 0:printf("%d/%d/%d比%d/%d/%d早", e1, e2, e3, d1, d2, d3);break;
}
return 0;
}
``````

https://my.oschina.net/u/4785181/blog/4876616