void homework01(int age)
{
printf("请输入年龄:");
scanf("%d", &age);
if (age >= 18)
{ printf("成年\n"); }
else { printf("未成年\n"); }
}
void homework02(int day)
{
printf("请输入:");
scanf("%d", &day);
if (day >= 1 && day <= 5)
{ printf("工作日\n"); }
else if (day == 6 || day == 7)
{ printf("休息日\n"); }
else { printf("输入有误\n"); }
}
void homework03(int month)
{
printf("请输入月份:");
scanf("%d", &month);
if (month == 3 || month == 4 || month == 5)
{ printf("%d月为春季\n", month); }
else if (month == 6 || month == 7 || month == 8)
{
printf("%d月为夏季\n", month);
}
else if (month == 9 || month == 10 || month == 11)
{
printf("%d月为秋季\n", month);
}
else if(month==12||month==1||month==2)
{ printf("%d月为冬季\n"); }
else { printf("输入有误\n"); }
}
void homework04(int x)
{
float y; printf("请输入一个整数:");
scanf("%d", &x);
if (x >= 25)
{ y = (float)x / 3 + x / 2; printf("f(x)=%f\n", y);}
else if (x >= 0 && x < 25)
{ y = x*x; printf("f(x)=%f\n", y);}
else { y = -x; printf("f(x)=%f\n", y); }
}
void main()
{ int age;
homework01(age);
int day;
homework02(day);
int month;
homework03(month);
int x;
homework04(x);
}
你的主函数中,age,day,month,x都需要赋初值,不然就会报错