c语言程序
夏之序曲-梦
这个作者很懒,什么都没留下…
展开
-
数列求和
#includeint Fuhao(i);int main(){ int i,n; double total=0; printf("Please input n:"); scanf("%d",&n); if(n=1000) printf("Input error!\n"); else { for(i=1;i<=n;i++) total+=Fuhao(i)*(dou原创 2015-01-17 18:18:31 · 482 阅读 · 0 评论 -
指针变量作为函数参数实现对输入的两个整数按大小顺序输出
#includevoid swap(int *p1,int *p2);int main(){ int a,b; int *pointer_1,*pointer_2; printf("please enter a and b:"); scanf("%d,%d",&a,&b); pointer_1=&a; pointer_2=&b; if(a<b) swap(pointer_1原创 2015-01-17 18:39:20 · 3568 阅读 · 0 评论 -
火爆的一乐面馆
#include#define MAX 10int main(){ int lieshu,i,j; double lamiantime,kaoroutime,yinliaotime,time,temp; double timetotal[MAX]; char str[MAX][18]; printf("请输入现在队伍的列数:\n"); scanf("%d",&lieshu); if(lieshu>原创 2015-01-19 14:02:44 · 1026 阅读 · 0 评论 -
静态局部变量求阶乘
#includeint main(){ int fun(int n); int i,n; printf("Please input n: "); scanf("%d",&n); printf("Output:\n"); for(i=1;i<=n;i++) { printf("%d!=%d\n",i,fun(i)); } return 0;}int fun(int n)原创 2015-01-17 18:10:35 · 1104 阅读 · 0 评论 -
四舍五入
#includeint main(){ double num; int n; while(num!=0) { printf("Please input num and n:"); scanf("%lf %d",&num,&n); printf("Output:\n%.*lf\n",n,num); } return 0;}原创 2015-01-17 18:24:57 · 401 阅读 · 0 评论 -
显示菱形
#includevoid KongGe(int n,int i);int main(){ int i,n,k=0; while(n!=0) { if(n==1) { printf("Enter Error!\n"); return 0; } printf("Please input n: "); scanf("%d",&n); for(i=0;i<n原创 2015-01-17 18:26:22 · 487 阅读 · 0 评论 -
线性链表的建立与显示
#include#includetypedef int ElemType;typedef struct Node{ ElemType data; struct Node*next;}LNode;void createLinkList(LNode*head);void displayLinkList(LNode*head);int main(){ LNode*head; h原创 2015-01-17 18:35:24 · 539 阅读 · 0 评论 -
指针的应用
#includeint main(){ char a[10]={'1','2','3','4','5','6','7','8','9',0},*p; int i; i=8; p=a+i; printf("%s %s\n",p-3,a); return 0;}原创 2015-01-17 18:45:11 · 342 阅读 · 0 评论 -
最大公约数
#includeint main(){ int a,b,k,i; printf("Please input a and:"); scanf("%d %d",&a,&b); if(a>1000||a1000||b<=0) { printf("Output:\nInput error!\n"); return 0; } else { if(a<b) { k=a原创 2015-01-17 19:19:21 · 412 阅读 · 0 评论 -
卡布列克常数
#includeint count=0;void vr6174(int num);void parse_sort(int num,int *each);void max_min(int *each,int *max,int *min);int main(){ int n; printf("Please input n: "); scanf("%d",&n); printf("O原创 2015-01-17 18:11:46 · 1888 阅读 · 2 评论 -
输入月份显示多少天
#includeint main(){ int month,day; printf("输入您想知道的月份天数:\n"); scanf("%d",&month); while(month>=1&&month<=12) { switch(month) { case 1:case 3:case 5:case 7:case 8:case 10:case 12: day=31原创 2015-01-17 18:17:08 · 654 阅读 · 0 评论 -
显示相对应的图案
#includevoid Print(int num,int kong,int MAX);void Printdown(int num,int kong);void KongGe(int num);int main(){ int num,kong,MAX; while(MAX!=0) { num=0,kong=0; printf("Please input a number原创 2015-01-17 18:32:38 · 466 阅读 · 0 评论 -
求一元二次方程的根
#include#includeint main(){ void t1(int a,int b,int c); void t2(int a,int b,int c); void t3(int a,int b,int c); int a,b,c,delta; double ans0,ans1,sqrt_delta,realpart,imagpart; printf("Please原创 2015-01-17 18:23:48 · 541 阅读 · 0 评论 -
数字分解成质因数
#includeint main(){ int num,i; while(num!=0) { printf("Input a number: "); scanf("%d",&num); printf("%d=",num); for(i=2;i<num;i++) { while(num!=i) { if(num%i==0) { pr原创 2015-01-17 18:19:44 · 616 阅读 · 0 评论 -
读取字符并校验和
#includeint main(){ int line=0; int at_beginning=1; char ch; signed char checksum= -1; while((ch = getchar()) != EOF) { if(at_beginning == 1) { line += 1; at_beginning = 0; printf原创 2015-01-19 12:06:22 · 463 阅读 · 0 评论 -
输入任意一点坐标,求建筑高度
#includeint main(){ int x1=2,y1=2,x2=-2,y2=2,x3=2,y3=-2,x4=-2,y4=-2; double x,y; printf("请输入x和y的值:"); scanf("x=%lf,y=%lf",&x,&y); if(((x-x1)*(x-x1)+(y-y1)*(y-y1))<=1) { printf("建筑高度为10m\n");原创 2015-01-17 16:22:45 · 1248 阅读 · 0 评论 -
火爆的一乐拉面
#include#define MAX 10int main(){ int lieshu,i,j; double lamiantime,kaoroutime,yinliaotime,time,temp; double timetotal[MAX]; char str[MAX][18]; printf("请输入现在队伍的列数:\n"); scanf("%d",&lieshu);原创 2015-01-17 18:07:14 · 1187 阅读 · 0 评论 -
牛顿迭代法求方程的根
#include#includedouble Resolve(double a,double b,double c,double d);double f(double x,double a,double b,double c,double d);double f1(double x,double a,double b,double c);int main(){ double a,b,原创 2015-01-17 18:12:26 · 634 阅读 · 0 评论 -
判断是否闰年
#includeint main(){ int year; while(year!=0) { printf("Input a year: "); scanf("%d",&year); if(year%100==0) { if(year%400==0) printf("%d is leap year.\n",year); else printf(原创 2015-01-17 18:14:02 · 417 阅读 · 0 评论 -
输入任意一点坐标,求建筑高度
#includeint main(){ int x1=2,y1=2,x2=-2,y2=2,x3=2,y3=-2,x4=-2,y4=-2; double x,y; printf("请输入x和y的值:"); scanf("x=%lf,y=%lf",&x,&y); if(((x-x1)*(x-x1)+(y-y1)*(y-y1))<=1) { printf("建筑高度为10m\n");原创 2015-01-17 18:16:16 · 958 阅读 · 0 评论 -
指针的简单比较
#includevoid Jiaohuanzhi1(int a,int b);void Jiaohuanzhi2(int *x,int *y);int main(){ /*int a,b,*x,*y; printf("请输入a,b的值:"); scanf("%d %d",&a,&b); x=&a; y=&b; Jiaohuanzhi1(a,b); printf("a=%d,b原创 2015-01-17 18:40:59 · 461 阅读 · 0 评论 -
最小公倍数
#includeint main(){ int a,b,k,t,i; printf("Please input a and:"); scanf("%d %d",&a,&b); if(a>1000||a1000||b<=0) { printf("Output:\nInput error!\n"); return 0; } else { if(a<b) { k原创 2015-01-19 12:07:32 · 560 阅读 · 0 评论 -
进制转化
#includeint main(){ int num; printf("Please input a number:"); scanf("%d",&num); if(num<0) printf("-%o -%x\n",-num,-num); else printf("%o %x\n",num,num); return 0;}原创 2015-01-17 18:08:52 · 415 阅读 · 0 评论 -
显示菱形改
#includevoid KongGe(int n,int i);void print(int i,int n,int k);void printDown(int i,int n,int k);int main(){ int i,n,k=0; /*while(n!=0) { if(n==1) { printf("Enter Error!\n"); return原创 2015-01-17 18:28:22 · 523 阅读 · 0 评论