91学习

陪伴你每一天!

判断月份属于哪个季节

#include <stdio.h>int main(){ int month; printf("please enter a month:\n"); scanf("%d",&month); switch(month){ case 3: case 4: case 5: printf("%d  is spring\n",month); break; case 6: case 7: case 8: pri

switch()在C语言中多选择

#include <stdio.h>int main(){ char cGrade; printf("please enter your grade\n"); scanf("%c",&cGrade); printf("Grade is about:"); switch(cGrade){ case 'A': printf("90~100\n"); break; case '

条件运算符(表达式1?表达式2:表达式3)

#include <stdio.h>int main(){ int jour,fee; printf("the milieage is taxi go:\n"); scanf("%d",&jour); fee=(jour<3)?6:6+(jour-3)*2; printf("the cost of get a taxi is %d\n",fee); return 0;}

根据输入的日期判定在干什么

#include <stdio.h>int main(){ int iDay=0; int Monday=1,Tuesday=2,Wednesday=3,Thursday=4,Friday=5,Saturday=6,Sunday=7; printf("enter a day of week to get course:\n"); scanf("%d",&iDay); if(iDay>Friday){ if(iDay==Satur

根据输入数字确定图形面的形状

#include <stdio.h>int main(){ int num; printf("please enter a num:"); scanf("%d",&num); if(num==1){ printf("its main view is triangle\n"); }else if(num==2){ printf("the top view of the cone is circular\n

if..elseif...的应用

     比如设计一个过关的小游戏场景,根据提示输入一个数字,然后根据数字进入相应的关卡。    #include <stdio.h>int main(){ int num; printf("please enter cencorship:"); scanf("%d",&num); if(num==1){ printf("the current into first

商品竞猜游戏(用C知识)

   在C语言中,可以用if...else编写出一个选择游戏,选择竞猜商品价格。    如下:#include <stdio.h>int main(){ int price=97,gue; printf("please enter a number:\n"); scanf("%d",&gue); if(gue<price){ printf("you guess the numbe

判断输入的年份是闰年还是不是闰年

#include <stdio.h>int main(){ int year; printf("please enter a year\n"); scanf("%d",&year); if((year%4==0)&&(year%100!=0)||(year%400==0)){ printf("%d is a leap year\n",year); } else{ printf("%d i

利用C语言构造就餐环境

   实例如下:比如客人到某地就餐,你可以根据人数选择就餐的安排餐位,及就餐环境。具体实例如下:#include <stdio.h>int main(){ int num; puts("the number of meals:"); scanf("%d",&num); if(num<=8) { printf("Arrange %d people dining table\n",num);

用C语言判断是否通过考试

本实例可以判断一个人成绩大于60通过考试,小于60分未通过考试。#include <stdio.h>int main(){ int score; puts("请输入你的考试成绩:"); scanf("%d",&score); if(score>60){ printf("your grade is %d\n",score); printf("pass the exam\n"); } if(