![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C语言
Z_Blue_sky
这个作者很懒,什么都没留下…
展开
-
输出4x4阶矩阵的最大值,最小值及…
# include "stdio.h"# define N 4int zuixiao(int d[N][N]){ int i,j,x=d[0][0],t=0; for(i=0;i for(j=0;j if(x>d[i][j]) x=d[i][j]; return (x);}int zuida(int d[N][N]){ int i,j,x=0,原创 2015-01-11 15:55:03 · 3139 阅读 · 0 评论 -
输入成绩,按照平均分从高到低输出
# include "stdio.h"# define M 3# define N 4int main(void){ float d[M][N],sum,x; int i,j,t; for(i=0;i { sum=0; printf("请输入第%d个学生的3门课的成绩:",i+1); for(j=0;j { scanf("%f",原创 2015-01-11 15:58:54 · 2253 阅读 · 0 评论 -
二维数组最大值
# include "stdio.h"# define N 3# define M 4int max(int b[N][M]){ int i,j,t; t=b[0][0]; for(i=0;i for(j=0;j if(t t=b[i][j]; return(t);}int main(void){ int a[N][M],i,j原创 2015-01-11 15:58:17 · 470 阅读 · 0 评论 -
素数的判断
# include "stdio.h"int main(void){ int x,i,t=0; printf("请输入要判断的正整数:"); scanf("%d",&x); for(i=2;i if(x%i==0) { t=1; i=x; } if(t==0) printf("该数为素数\n"); else原创 2015-01-11 15:57:46 · 301 阅读 · 0 评论 -
所有字符变大写
# include "stdio.h"int main(void){ char c; printf("请输入一个字母:"); c=getchar(); if((c>='A'&&c='a'&&c if(c>='a'&&c { putchar(c-32); putchar('\n'); } else {原创 2015-01-11 15:57:14 · 480 阅读 · 0 评论 -
将一个5*5的矩阵中最大的元素放在…
# include "stdio.h"# define N 5int paixu(int d[N][N]){ int i,j,k=0,x,b[25]; for(i=0;i for(j=0;j { b[k]=d[i][j]; k++; } for(i=0;i for(j=i+1;j { if(b[i]>b[j])原创 2015-01-11 15:54:58 · 2232 阅读 · 0 评论 -
将一个整数对调并输出
# include "stdio.h"int main(void){ long x; int d[100],j,i=0; printf("请输入整数:"); scanf("%ld",&x); while(x!=0) { d[i]=x; x=x/10; i++; } printf("对调后的结果为:"); for(j=0;j prin原创 2015-01-11 15:59:05 · 586 阅读 · 0 评论 -
求Fibonacci数列的前30项
# include "stdio.h"int main(void){ long a=1,b=1,c,i; printf("前30项为:%ld %ld",a,b); for(i=3;i { c=a+b; a=b; b=c; printf("%ld",c); } printf("\n");}原创 2015-01-11 15:57:38 · 3595 阅读 · 0 评论 -
四则运算测试
# include "stdio.h"# include "time.h"# include "stdlib.h"int main(void){ int i,j=0,x,y,n,t,a,b; float d,c; srand((unsigned)time(NULL)); printf("请输入测试范围(允许出现的最大数):"); scanf("%d",&x); pr原创 2015-01-11 15:57:32 · 473 阅读 · 0 评论 -
1-100的阶乘相加
# include "stdio.h"int main(void){ int i,j; double t,sum=0; for(i=1;i { t=1; for(j=1;j t*=j; sum+=t; } printf("和为:%.3lf\n",sum);}原创 2015-01-11 15:57:12 · 1760 阅读 · 1 评论 -
矩阵的相加
# include "stdio.h"int main(void){ int a[100][100],b[100][100],i,j,c,d; printf("请输入需要相加的矩阵的行数与列数:"); scanf("%d %d",&c,&d); printf("请输入第一个矩阵:\n"); for(i=0;i for(j=0;j scanf("%d",原创 2015-01-11 15:59:00 · 634 阅读 · 0 评论 -
循环队列的常用操作(初始化,判断…
#include#includetypedef struct Queue{ int*pBase; intfront; intrear;}QUEUE, *PQUEUE ;void init_queue(PQUEUE);//初始化队列void full_queue(PQUEUE);//判断队列是否已满void en_queue(PQUEUE, int);原创 2015-01-11 15:59:36 · 897 阅读 · 0 评论 -
输入学生成绩,性别,学号,计算平…
# include "stdio.h"# define N 3struct fengshu{ int chinese; int math; int english; int Clanguage;};struct xinxi{ int num; int ave; char name[15]; char sex; struct fengshu score原创 2015-01-11 15:55:42 · 853 阅读 · 0 评论 -
按字典顺序排序
# include "stdio.h"# include "string.h"# define N 4int main(void){ char s[N][20],t[20]; int i,j; printf("请输入%d个姓名:\n",N); for(i=0;i gets(s[i]); for(i=0;i for(j=i+1;j if(str原创 2015-01-11 15:59:10 · 918 阅读 · 0 评论 -
十进制转换为二进制
# include "stdio.h"int main(viod){ int d[30],i=0,n; printf("请输入整数:"); scanf("%d",&n); while(n>0) { d[i++]=n%2; n=n/2; } printf("转换为二进制为:"); for(i--;i>=0;i--) printf("%d",原创 2015-01-11 15:58:52 · 394 阅读 · 0 评论 -
输入月份显示英文
# include "stdio.h"int main(void){ int x; do { printf("请输入月份号(输入0时结束):"); scanf("%d",&x); switch(x) { case 0:;break; case 1:printf("January\n");break; case 2:原创 2015-01-11 15:58:49 · 502 阅读 · 0 评论 -
求2次方程的解
# include "stdio.h"# include "math.h"int main(void){ float b,a,c,x1,x2,x; printf("请输入方程的参数a,b,c:"); scanf("%f %f %f",&a,&b,&c); if(a>0) { if((b*b-4*a*c) printf("该方程无解!!!\n");原创 2015-01-11 15:57:20 · 375 阅读 · 0 评论 -
字符串比较函数收获
错误程序:#include#include#define M 2 //二维长度为2#define N 2int main (){ chars[N][M]; inti,j; for(i=0;i { printf("Please input:"); scanf("%s",&s[i]); } for(原创 2015-01-11 15:56:21 · 348 阅读 · 0 评论 -
一个算法从顺序表L中删除所有值为X…
#include#define N 20typedef struct{ intdata[N]; inttop;}list;list* initlist(){ list*s; s=(list*)malloc(sizeof(list)); s->top=-1; returns;}list * pushlist(list *原创 2015-01-11 15:56:32 · 4513 阅读 · 0 评论 -
删除字符串中的指定字符
# include "stdio.h"# define N 100char shanchu(char s[N],char ch){ int i,j; for(i=0;i if(ch==s[i]) { for(j=i;j s[j]=s[j+1]; }}main(){ char s[N],c; printf("请原创 2015-01-11 15:55:01 · 696 阅读 · 0 评论 -
从键盘输入n个数,对n个数进行排序
# include "stdio.h"# define N 10main(){ int i,j,t,d[10]; printf("Please input:"); for(i=0;i scanf("%d",&d[i]); for(i=0;i for(j=i+1;j { if(d[i]>d[j])原创 2015-01-11 15:55:31 · 5453 阅读 · 1 评论 -
60分以下为D
# include "stdio.h"int main(void){ int x; printf("请输入分数:"); scanf("%d",&x); if(x printf("%d分的等级为D\n",x); else if(x printf("%d分的等级为C\n",x); else if(x printf("%d分的等级为B\n",x);原创 2015-01-11 15:56:56 · 336 阅读 · 0 评论 -
56岁以上退休
# include "stdio.h"int main(void){ int x; printf("请输入年龄:"); scanf("%d",&x); if(x printf("不在公司员工年龄范围内,输入有误!!!\n"); else if(x>=22&&x printf("担任外勤业务员\n"); else if(x printf("担任内勤原创 2015-01-11 15:56:53 · 369 阅读 · 0 评论 -
简单计算器
# include "stdio.h"int main(void){ char c; float a,b; printf("请输入:"); scanf("%f%c%f",&a,&c,&b); switch(c) { case'+':printf("%.3f%c%.3f=%.3f\n",a,c,b,a+b);break; case'-':printf(原创 2015-01-11 15:57:01 · 337 阅读 · 0 评论 -
王曙燕《c语言程序设计》习题5.7
# include "stdio.h"int main(void){ int i,n,t,j; printf("请输入n的值:"); scanf("%d",&n); for(i=1;i { for(j=1;j printf(" "); for(t=n-i+1;t>0;t--) printf("*"); printf("\n")原创 2015-01-11 15:58:04 · 772 阅读 · 0 评论 -
键盘输入N个数之和
# include "stdio.h"int main(void){ int x,i,j,t=1; printf("100~200的素数有:"); for(i=100;i { t=1; for(j=2;j if(i%j==0) { t=0; j=i; } if(t==1) p原创 2015-01-11 15:57:56 · 486 阅读 · 0 评论 -
1-100相乘
# include "stdio.h"int main(void){ int n=1; double fac=1; while(n { fac*=n; n++; } printf("1~100相乘的结果为%.0lf\n",fac);}原创 2015-01-11 15:57:43 · 913 阅读 · 0 评论 -
100-200间的所有素数
# include "stdio.h"int main(void){ int x,i,j,t=1; printf("100~200的素数有:"); for(i=100;i { t=1; for(j=2;j if(i%j==0) { t=0; j=i; } if(t==1) p原创 2015-01-11 15:57:03 · 418 阅读 · 0 评论 -
求两正整数的最大公约数和最小公倍…
# include "stdio.h"int yue(int a,int b){ int i; if(a>b) { i=a; a=b; b=i; } for(i=a;i>0;i--) if(a%i==0&&b%i==0) return(i);}int bei(int a,int b,intc){ int j; j原创 2015-01-11 15:55:08 · 764 阅读 · 0 评论 -
n个人信息包括准考证号,姓名,年…
# include "stdio.h"# define N 2struct st{ char name[20]; char num[20]; int age; union { intscore; chargrade; }result;};main(){ struct st s[N]; int i,x,j; for(i=0;i原创 2015-01-11 15:55:18 · 756 阅读 · 0 评论 -
商品信息表,除了商品号,商品名,…
#include "stdio.h"# define N 2# include "string.h"struct type1{ char danwei[20]; char num[15];};struct type2{ char date[20];};struct things{ char haoma[15]; char name[20]; char原创 2015-01-11 15:55:23 · 1162 阅读 · 0 评论 -
找出n以内所有完数并输出其因子。…
# include "stdio.h"# define N 200main(){ int i,t,j,sum; for(i=1;i { sum=0; for(j=1;j { t=i%j; if(t==0) sum+=j; } if(sum==i) { printf("完数:%d,因子原创 2015-01-11 15:55:29 · 2750 阅读 · 0 评论 -
统计一个字符串中的大小写字母个数…
# include "stdio.h"# define N 100main(){ char s[N],f; int i,t,a=0,b=0,c=0,d=0,e=0; printf("请输入字符串:"); gets(s); for(i=0;i { f=s[i]; if(f!='\0') {if(f='a') a++; else原创 2015-01-11 15:55:34 · 2945 阅读 · 0 评论 -
职工信息的整体赋值
# include "stdio.h"struct data{ int y; int m;};struct worker{ char num[20]; char name[20]; struct data day; floatsalary; floatother; floatcost; };in原创 2015-01-11 15:58:12 · 433 阅读 · 0 评论 -
字符串排序
# include "stdio.h"int insert(char s[11]){ int i,j,t; for(i=1;i { t=s[i]; j=i-1; while((j>=0)&&(t { s[j+1]=s[j]; j--; } s[j+1]=t; }}int main(void){ c原创 2015-01-11 15:58:25 · 353 阅读 · 0 评论 -
实现两个矩阵的相乘(指针)
# include "stdio.h"# define N 2chen(int (*p1)[N],int (*p2)[N],int m){ int *q1,*q2,(*u)[N]; u=p1+m; for(;p1 for(q1=*p1,q2=*p2;q1 *q1*=*q2;}print(int (*p)[N],int m){ int *q,(*u原创 2015-01-11 15:55:57 · 1677 阅读 · 0 评论 -
用指针实现二维矩阵的输入与输出
# include# define N 4main(){ int a[N][N],b[N][N],*p,i=0; printf("请输入%d*%d阶矩阵:\n",N,N); for(p=*a;p scanf("%d",p); zhuan(a); printf("转置结果为:\n"); for(p=*b;p { printf("%d",*p,i++原创 2015-01-11 15:56:00 · 1167 阅读 · 0 评论 -
编写一个对n个数据从大到小的排序C…
# include "stdio.h"# define N 3# define M 4main(){ int d[N][M],i,j,k,x; float t[N]; printf("please input:"); for(i=0;i for(j=0;j scanf("%d",&d[i][j]); jun(d,t); for(k=0;原创 2015-01-11 15:55:06 · 4818 阅读 · 0 评论 -
用结构体数组存储30名学生的学号,…
# include "stdio.h"# define N 30struct fengshu{ int chinese; int math; int english; int Clanguage;};struct xinxi{ int num; int ave; char name[15]; char sex; struct fengshu scor原创 2015-01-11 15:55:13 · 2094 阅读 · 0 评论 -
矩阵的转置,调用函数
# include "stdio.h"# define N 4int zhuan(int d[N][N]){ int i,a,j,t[N][N]; for(i=0;i for(j=i;j { a=d[i][j]; d[i][j]=d[j][i]; d[j][i]=a; }}main(){ int d[N][N],i,j,t[N]原创 2015-01-11 15:55:39 · 1300 阅读 · 0 评论