c语言程序设计实例求C语言程序设计实例,要100行以上

c语言程序设计实例  时间:2021-08-24  阅读:()

求c语言程序设计实例80到100行

#include <stdio.h> /*头函数*/ int main(void) /*主函数*/ { char c; /*指定c成为字符变量*/ printf("请输入0到9的任意一个数字 "); /*输出请输入0到9的任意一个数字*/ c=getchar(); /*输入一个字符*/ while(c>=48&&c<=57) /*c的取值范围*/ { getchar(); switch(c) /*根据c的值转换*/ { case '0': printf("你喜欢奋斗吗? "); /*假如c=0,输出你喜欢奋斗吗?*/ break; /*中断跳出,执行c=getchar()*/ case '1': printf("你喜欢当模特吗? "); /*假如c=1,输出你喜欢当模特吗?*/ break; /*中断跳出,执行c=getchar()*/ case '2': printf("你喜欢和谐吗? "); /*假如c=2,输出你喜欢和谐吗?*/ break; /*中断跳出,执行c=getchar()*/ case '3': printf("你喜欢道家吗? "); /*假如c=3,输出你喜欢道家吗?*/ break; /*中断跳出,执行c=getchar()*/ case '4': printf("你是广东人吗? "); /*假如c=4,输出你是广东人吗?*/ break; /*中断跳出,执行c=getchar()*/ case '5': printf("你喜欢武术吗? "); /*假如c=5,输出你喜欢武术吗?*/ break; /*中断跳出,执行c=getchar()*/ case '6': printf("祝你一帆风顺! "); /*假如c=6,输出祝你一帆风顺!*/ break; /*中断跳出,执行c=getchar()*/ case '7': printf("观察等待好机会! "); /*假如c=7,输出观察等待好机会!*/ break; /*中断跳出,执行c=getchar()*/ case '8': printf("你喜欢交际吗? "); /*假如c=8,输出你喜欢交际吗?*/ break; /*中断跳出,执行c=getchar()*/ case '9': printf("追求完美吧! "); /*假如c=9,输出追求完美吧!*/ break; /*中断跳出,执行c=getchar()*/ } c=getchar(); /*再输入一个字符*/ } return 0; /*返回值*/ }

c语言程序设计案例。要100行左右的。。核心代码50行左右,可以在TC上运行的。拜谢了,,,

下面是个C++代码。

估计你会用上,呵呵。

~!~ #include "stdio.h" #include "stdlib.h" class Student { public: int id; int eng; int math; puter; double avg; double total; Student(){id=-1;eng=-1;;math=puter=-1;avg=-1;total=-1;}; double Aveage() { return avg=(double)(eng+puter)/(double)3; }; double Sum() { return total=(double)(eng+puter); }; }; void EX(Student*A,Student*B)//排序 { Student temp; temp=*A; *A=*B; *B=temp; } void PX(Student* A,int s) { Student* R=new Student[s]; for(int i=0;i<s;i++) { for(int j=i+1;j<s;j++) { if((A+i)->avg<(A+j)->avg) EX(A+i,A+j); } } }; void main() { int s=-1; printf("请输入学生个数 "); scanf("%d",&s); Student *all=new Student[s]; printf("eng,puter "); for(int i=0;i<s;i++) { scanf("%d %d %d",&(all+i)->eng,&(all+i)->math,&(all+i)-&puter);//输入以空格为间隔以回车为确定 (all+i)->Aveage();(all+i)->Sum();(all+i)->id=i+1; } PX(all,s); printf("ID,eng,puter,avg,total "); for(int j=0;j<s;j++) { printf("%d,%d,%d,%d,%2.2f,%d ",(all+j)->id,(all+j)->eng,(all+j)->math,(all+j)-&puter,(all+j)->avg,(all+j)->total); } }

c语言编程实例

#include<stdio.h> int main(void) { int i,j; for(i = 1;i <=4;i++) { for(j = 1;j <= i;j++) printf("%d",j); printf(" "); } printf(" "); return 0; } 这是最简单的,可以有附加功能。

求C语言程序设计实例,要100行以上

Problem Description: The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will , in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each .

For a given request list, you are pute the total time spent to fulfill the requests on the list. The elevator is on the 0th floor at the beginning and does not have to return to the ground floor when the requests are fulfilled.

Input: There are multiple test cases. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100. A test case with N = 0 denotes the end of input. This test case is not to be processed.

Output Print the total time on a single line for each test case.

Sample Input 1 2 3 2 3 1 0

Sample Output 17 41

Here is my code:

#include<stdio.h> int time(int a,int b) { if(a==b)return 0; else if(a<b) return (b-a)*6; else return (a-b)*4; } int main() { int n,start,end,ans; while(1) { scanf("%d",&n); if(n==0)break; start=0;ans=0; while(n--) { scanf("%d",&end); ans+=time(start,end)+5; start=end; } printf("%d ",ans); } return 0; } 说明:程序代码的多少不是评价一个程序质量的唯一标准。

Megalayer(159元 )年付CN2优化带宽VPS

Megalayer 商家我们还算是比较熟悉的,商家主要业务方向是CN2优化带宽、国际BGP和全向带宽的独立服务器和站群服务器,且后来也有增加云服务器(VPS主机)业务。这次中秋节促销活动期间,有发布促销活动,这次活动力度认为还是比较大的,有提供香港、美国、菲律宾的年付VPS主机,CN2优化方案线路的低至年付159元。这次活动截止到10月30日,如果我们有需要的话可以选择。第一、特价限量年付VPS主...

云基最高500G DDoS无视CC攻击(Yunbase),洛杉矶CN2GIA、国内外高防服务器

云基成立于2020年,目前主要提供高防海内外独立服务器用户,欢迎各类追求稳定和高防优质线路的用户。业务可选:洛杉矶CN2-GIA+高防(默认500G高防)、洛杉矶CN2-GIA(默认带50Gbps防御)、香港CN2-GIA高防(双向CN2GIA专线,突发带宽支持,15G-20G DDoS防御,无视CC)、国内高防服务器(广州移动、北京多线、石家庄BGP、保定联通、扬州BGP、厦门BGP、厦门电信、...

小渣云(36元/月)美国VPS洛杉矶 8核 8G

小渣云 做那个你想都不敢想的套餐 你现在也许不知道小渣云 不过未来你将被小渣云的产品所吸引小渣云 专注于一个套餐的商家 把性价比 稳定性 以及价格做到极致的商家,也许你不相信36元在别人家1核1G都买不到的价格在小渣云却可以买到 8核8G 高配云服务器,并且在安全性 稳定性 都是极高的标准。小渣云 目前使用的是美国超级稳定的ceranetworks机房 数据安全上 每5天备份一次数据倒异地 支持一...

c语言程序设计实例为你推荐
网络的好处网络的优点?互联网接入无线路由器怎样接入互联网什么是机器码电脑的机器码是什么?无线存储无线摄像头里的远程存储和本地存储是怎么回事?上海网络维护公司上海嘉定网络公司 做监控的和综合布线的有那几家小时代发布会完整版郭敬明《小时代2.0虚铜时代》限量版上市时间伙伴云毒霸中的云安全指的是什么意思?lightninglightning闪电动词是甚么系统镜像原版系统镜像是什么意思和其他的有什么区别网络嗅探器网络嗅探器有哪些 常用网络嗅探器推荐介绍
海外域名 虚拟主机服务商 网站备案域名查询 免费cn域名 申请个人网页 英文站群 个人空间申请 台湾谷歌地址 大容量存储器 泉州移动 免费智能解析 昆明蜗牛家 支付宝扫码领红包 支持外链的相册 安徽双线服务器 石家庄服务器托管 美国迈阿密 广东主机托管 alexa搜 ftp是什么东西 更多