范文无忧网范文学习范文大全

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

04月23日 编辑 fanwen51.com

[c语言程序设计职工工资]你要的是命令行还是图形界面?如果是命令行可以考虑下如果是图形界面的话200分少了点,看看吧.--------------------------------------------既然不是图形界面,代码就简单.不过...+阅读

求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 stop, 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 stop.

For a given request list, you are to compute 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 int time(int a,int b) { if(a==b)return 0; else if(a

C语言编程100例变形题

#include "stdio.h"#include "conio.h"

main()

{

int i,j,k;

printf("\n");

for(i=0;i<=8;i++) /*以下为三重循环*/

for(j=0;j<=8;j++)

for (k=0;k<=8;k++)

{

if(i!=1&i!=2&i!=4&i!=5&

j!=6&j!=1&j!=2&j!=4&j!=5&

k!=6&k!=1&k!=2&k!=4&k!=5&k!=6)

{

if (i!=k&i!=j&j!=k)/*确保i、j、k三位互不相同*/

printf("%d,%d,%d\n",i,j,k);

}

}

getch();

}

c语言程序设计案例。要100行左右的。

下面是个C++代码。估计你会用上,呵呵。~!~

#include "stdio.h"

#include "stdlib.h"

class Student

{

public:

int id;

int eng;

int math;

int computer;

double avg;

double total;

Student(){id=-1;eng=-1;;math=-1;computer=-1;avg=-1;total=-1;};

double Aveage()

{

return avg=(double)(eng+math+computer)/(double)3;

};

double Sum()

{

return total=(double)(eng+math+computer);

};

};

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

{

for(int j=i+1;j

{

if((A+i)->avg<(A+j)->avg)

EX(A+i,A+j);

}

}

};

void main()

{

int s=-1;

printf("请输入学生个数\n");

scanf("%d",&s);

Student *all=new Student[s];

printf("eng,math,computer\n");

for(int i=0;i

{

scanf("%d %d %d",&(all+i)->eng,&(all+i)->math,&(all+i)->computer);//输入以空格为间隔以回车为确定

(all+i)->Aveage();(all+i)->Sum();(all+i)->id=i+1;

}

PX(all,s);

printf("ID,eng,math,computer,avg,total\n");

for(int j=0;j

{

printf("%d,%d,%d,%d,%2.2f,%d\n",(all+j)->id,(all+j)->eng,(all+j)->math,(all+j)->computer,(all+j)->avg,(all+j)->total);

}

}

c语言程序经典实例

#include

void printk(void)

{

printf(" ");

}

void printx(void)

{

printf("*");

}

void main()

{

int n,i,j;

printf("Please input n:");

scanf("%d",&n);

for (i = 0;i <= 2*n;i++)

{

if (i <= n)

{

for (j = 0;j < n-i;j++)

{

printk();

}

for(j = 0;j < 2*i+1;j++)

{

printx();

}

printf("\n");

}

if (i > n)

{

for (j = 0;j <= i-n-1;j++)

{

printk();

}

for (j = 0;j < 2*(2*n-i)+1;j++)

{

printx();

}

printf("\n");

}

}

}

延伸阅读:

求C语言编写的表白程序要代码呃,你还不如用vbs,网上也有一堆教程和例子,很简单,随便看一下就知道怎么写了。1234567891011121314 DimmyName,herName,myNameAns,herNameAnsmyName="池早早"herName="欧浩辰"MsgBox...

求一个示爱的小程序 C语言void a(int aa) {for(int i=0;i<aa;i++)printf(" ");} void b() {printf ("*");} char c(int cc) {printf("%c",cc);return 0;} int main() {a(6);b();a(3);b();a(5);b();a(3);b()...

c语言程序设计大赛试题我写了个程序,不知道能达到你的要求不? 主要的算法思路是若输入的数不能被11整除,就先用一个数组将输入数的每一位存起来,然后通过交换数组元素的位置达到重新排列数的目的,每次...

C语言程序设计题目#include char *strcpy(char *d,char *s) { char *p=d; while(*p++=*s++); return d; } char *strcat(char *d,char *s) { char *p=d; for(;*p;p++); strcpy(p,s); return d...

C语言程序设计试题结果 1 1 2 3 5 8 13 21 就是 第一次循环 屏幕上输出 1 1 1 + 1 = 2 1 + 2 = 3 第二次 屏幕上输出 2 3 2 + 3 = 5 3 + 5 = 8 第三次 屏幕上输出 5 8 5 + 8 = 13 13 + 8 = 21...

C语言程序设计C语言程序设计题,C程序设计题目:void main() { float num1,num2; /س定义两个实型运算数س/ char op;/س定义运算符,可以是+,-,س,/中的任何一个س/ printf("input expression: num1+...

c语言程序设计c语言程序设计,C程序设计:方法1: 启动VC时不要用图形界面,通过在命令提示符下输入:Msdev /useenv运行(注意啦/前面有个空格).它会强制使系统环境变量全高设置成正确值.而且,只需要使...

c语言程序设计入门c语言程序设计入门,C语言程序设计怎么学:自学c语言的话,建议你买本谭浩强的《C程序设计》(第四版)出版超过1100万册,成为最畅销的计算机科普书籍。还有配套的《c程序设计学习辅导...

C语言控制硬件的实例C语言控制硬件的实例,计算机控制系统中计算机在一个周期内要完成的任务:首先,以下写的东西不是复制粘贴,我会给你详细的说明、1,要知道,计算机的发展规律是离硬件越来越远,离人类的...

推荐阅读
图文推荐
栏目列表