1. 字符判断
输入一个字符,判断它如果是小写字母输出其对应大写字母;如果是大写字母输出其对应小写字母;如果是数字输出数字本身;如果是空格,输出“space”;如果不是上述情况,输出“other”。
#include <stdio.h>
int main()
{
char a,c;
int b;
printf("输入一个字符\n");
scanf("%c",&a);
if(a>='A'&&a<='Z')
{
c=a+32;
printf("%c\n",c);
}
else if(a>='a'&&a<='z')
{
c=a-32;
printf("%c\n",c);
}
else if(a>='0'&&a<='9')
{
printf("%d\n",b);
}
else if(a==' ')
{
printf("space\n",a);
}
else
{
printf("other\n",a);
}
return 0;
}

2. 年龄问题
输入一个学生的生日(年:月:日),并输入当前日期(年:月:日),计算该生的实际年龄(周岁)。
#include <stdio.h>
int main()
{
int a,b,c,d,e,f,g;
printf("请输入今天的日期\n");
scanf("%d,%d,%d",&a,&b,&c);
printf("请输入你的生日\n");
scanf("%d,%d,%d",&d,&e,&f);
if(b>e)
{
g=a-d;
}
else if(b<e)
{
g=a-d-1;
}
else if(b==e)
{
if(c>=d)
{
g=a-d;
}
else if(c<d)
{
g=a-d-1;
}
}
printf("你今年%d周岁了",g);
return 0;
}

3. 判断三角形类型 输入三个整数,判断由其构成的三角形的类型(等边三角形、等腰三角形、等腰直角三角形、直角三角形、一般三角形以及非三角形)
#include <stdio.h>
int main()
{
int a,b,c;
printf("输入三个数,并且用逗号隔开\n");
scanf("%d,%d,%d",&a,&b,&c);
if(a+b<=c||b+c<=a||a+c<=b)
{
printf("非三角形\n");
}
else if((a*a+b*b==c*c)||(b*b+c+c==a+a)||(a*a+c*c==b*b))
{
if(a==b||b==c||a==c)
{
printf("等腰直角三角形\n");
}
else
{
printf("直角三角形\n");
}
}
else if(a==b&&a==c&&b==c)
{
printf("等边三角形\n");
}
else if((a==b&&a!=c&&b!=c)||(b==c&&b!=a&&c!=a)||(a==c&&a!=b&&c!=b))
{
printf("等腰三角形\n");
}
else
{
printf("普通三角形\n");
}
return 0;
}

4. 看商品猜价格小游戏
include <stdio.h>
#include <stdlib#.h>
#include <time.h>
int main()
{
int a,b;
srand(time(NULL));
a=rand()%100;
printf("请输入你的价格\n");
scanf("%d",&b);
if(a==b)
{
printf("商品归你了\n");
}
else if(a>b)
{
printf("太小了\n");
}
else if(a<b)
{
printf("太大了\n");
}
return 0;
}

知识点总结:1:字符型数据为%c
2:随机数,时间一直改变所以<time.h>
3:else后面不能再加东西
4:周岁,要讨论过不过生日
实验三:题一:字符为%c否则无论输出什么为other
题二:周岁要讨论过不过生日,不只是单纯的-1
题三:大括号的匹配问题
题四:rand()%100的书写