c语言程序设计题库C语言编程题目。

c语言程序设计题库  时间:2021-07-20  阅读:()

c语言编程题目

//第一题 #include "stdio.h" double fun(int n) { double result=1.0; while (n>1 && n<170) /*********found*********/ result*=n--; /*********found*********/ return result; } main() { int n; printf("Enter an integer: "); scanf("%d",&n); printf(" %d!=%lg ",n,fun(n)); } //第二题 #include <stdio.h> #include <math.h> void fun(int a, int b, long *c) { *c=a%10*100+a/10+b/10*10+b%10*1000; } main() { int a,b; long c; printf("Input a, b:"); scanf("%d%d", &a, &b); fun(a, b, &c); printf("The result is: %ld ", c); }

一个C语言程序设计的题目(高分悬赏)

#include<stdio.h> struct student { int num;//学号 char name[20];//姓名 float chengji1,chengji2,chengji3;//成绩 float avg;//平均成绩 } ; void display(struct student stu[],int count); void paixu(struct student stu[],int count); int charu(struct student stu[],int count); void shanchu(struct student stu[],int count); struct student Input(); void main() { //声明结构数组 struct student stu[30]; int count=0;//count用来表示数组的元素的个数 char ch; printf("请输入学员信息:"); do { stu[count]=Input(); printf("是否继续?(y or n):"); fflush(stdin); ch=getchar(); count++; }while(ch=='Y'||ch=='y'); //输出显示函数 printf("排序之前的数组为: "); display(stu,count); printf("排序之后的数组为: "); paixu(stu,count); display(stu,count); int count1=charu(stu,count); shanchu(stu,count1); printf("删除之后的数组为: "); display(stu,count); } struct student Input() { struct student stu; float sum=0; printf(" 学号:"); scanf("%d",&stu.num); printf(" 姓名:"); fflush(stdin); gets(stu.name); printf(" 请输入第1门课的成绩:"); scanf("%f",&stu.chengji1); printf(" 请输入第2门课的成绩:"); scanf("%f",&stu.chengji2); printf(" 请输入第3门课的成绩:"); scanf("%f",&stu.chengji3); stu.avg=(stu.chengji1+stu.chengji2+stu.chengji3)/3; return stu; } void paixu(struct student stu[],int count)//排序 { struct student temp; for(int i=0;i<count;i++) { for(int j=0;j<count-i-1;j++) { if(stu[j].avg<stu[j+1].avg) { temp=stu[j+1]; stu[j+1]=stu[j]; stu[j]=temp; } } } } int charu(struct student stu[],int count) //插入 { int i,j; char ch; struct student t; printf("是否插入?(y or n):"); fflush(stdin); ch=getchar(); if(ch=='Y'||ch=='y') { printf(" 请输入要插入的学员信息:"); t=Input(); for(i=0;i<count;i++) { if(stu[i].avg<t.avg) break; } for(j=count;j>=i;j--) { stu[j+1]=stu[j]; } stu[i]=t; printf("插入之后的数组为: "); printf("学号 姓名 平均成绩 "); for(int i=0;i<count+1;i++) { printf("%d %s %.2f ",stu[i].num,stu[i].name,stu[i].avg); } } return count+1; } void shanchu(struct student stu[],int count) //删除 { int dno; int j,i; char ch; printf("是否删除?(y or n):"); fflush(stdin); ch=getchar(); if(ch=='Y'||ch=='y') { printf(" 请输入要删除的学员的学号:"); scanf("%d",&dno); for(i=0;i<count;i++) { if(stu[i].num==dno) break; } for(j=i;j<count-1;j++) { stu[j]=stu[j+1]; } } } void display(struct student stu[],int count) { printf("学号 姓名 平均成绩 "); for(int i=0;i<count;i++) { printf("%d %s %.2f ",stu[i].num,stu[i].name,stu[i].avg); } }

高分!C程序设计题目

我做的第一题: int sss(int x) { int i; int av; if(x==2) return 0; av=(int)sqrt(x*1.0); for(i=2;i<=av;i++) { if((x%i)==0) break; } if(i>av) return 1; else return 0; }

c语言编程题目

void main() { int a[5],b[5]; t=0,i,j,t; for(i=0;i<=4;i++) scanf("%d",&a[i]); for(i=0;i<=4;i++) if( (a[i]%10)%2==0 && (a[i]/10%10)%2==0 && (a[i]/100%10)%2==0 &&(a[i]/1000%10)%2==0 ) t++]=a[i]; for(i=0;i<4;i++) for(j=i+1;j<=4;j++) if(a[i]>a[j]) { t=a[j]; a[j]=a[i]; a[i]=t; } printf(&t=%d,num is"t); for(i=0;i&t;i++) printf(" %d",b[i]); printf(" "); for(i=0;i<=4;i++) printf("%d ",a[i]); getch(); }

c语言程序设计试题 y=1+1/2+1/4+1/6+1/8+...+1/1024 编写程序计算y的值

#include <stdio.h> int main(){ double s=1; int i; for(i=2;i<=1024;i+=2){ s+=1.0/i; } printf("%lf", s); return 0; }

C语言编程题目。

#include <stdio.h> #include <malloc.h>

int main() { int n, m; int i, j; int** p; int** q; scanf("%d%d", &n, &m); p = (int**)malloc(sizeof(int*)*n); for(i = 0; i != n; i++) *(p+i) = (int*)malloc(sizeof(int)*m); q = (int**)malloc(sizeof(int*)*m); for(i = 0; i != m; i++) *(q+i) = (int*)malloc(sizeof(int)*n); for(i = 0; i != n; i++) { for(j = 0; j != m; j++) { scanf("%d", (*(p+i))+j); } } for(i = 0; i != m; i++) { for(j = 0; j != n; j++) { q[i][j] = p[n-j-1][i]; } } for(i = 0; i != m; i++) { for(j = 0; j != n; j++) { printf("%d ", *(*(q+i)+j)); } printf(" "); } return 0; }

华纳云不限流量¥324/年,香港双向CN2(GIA)云服务器/1核1G/50G存储/2Mbps

华纳云(HNCloud Limited)是一家专业的全球数据中心基础服务提供商,总部在香港,隶属于香港联合通讯国际有限公司,拥有香港政府颁发的商业登记证明,保证用户的安全性和合规性。 华纳云是APNIC 和 ARIN 会员单位。主要提供香港和美国机房的VPS云服务器和独立服务器。商家支持支付宝、网银、Paypal付款。华纳云主要面向国内用户群,所以线路质量还是不错的,客户使用体验总体反响还是比较好...

spinservers:10Gbps带宽高配服务器月付89美元起,达拉斯/圣何塞机房

spinservers是一家主营国外服务器租用和Hybrid Dedicated等产品的商家,Majestic Hosting Solutions LLC旗下站点,商家数据中心包括美国达拉斯和圣何塞机房,机器一般10Gbps端口带宽,且硬件配置较高。目前,主机商针对达拉斯机房机器提供优惠码,最低款Dual E5-2630L v2+64G+1.6TB SSD月付89美元起,支持PayPal、支付宝等...

Spinservers:美国圣何塞服务器,双E5/64GB DDR4/2TB SSD/10Gbps端口月流量10TB,$111/月

spinservers怎么样?spinservers大硬盘服务器。Spinservers刚刚在美国圣何塞机房补货120台独立服务器,CPU都是双E5系列,64-512GB DDR4内存,超大SSD或NVMe存储,数量有限,机器都是预部署好的,下单即可上架,无需人工干预,有需要的朋友抓紧下单哦。Spinservers是Majestic Hosting Solutions,LLC旗下站点,主营美国独立...

c语言程序设计题库为你推荐
网络小说赚钱网络小说一百万点击率能挣多少钱?水冷机箱多少钱主机安一个水冷要多少钱?谷歌德语在线翻译德语翻译成中文,网龙吧刘谦吧 百度贴吧linksys无线路由器设置如何使用无线路由linksys wet11 在线等微软将停止支持32位Win10系统微软即将停止支持当前操作系统,如果不升级会怎么样色中色luntancoreldraw x6怎么抠图换背景cf服务器爆满CF老是服务器爆满操控人心如何操控自己的人生500人同时满足500人在线的性能测试jmeter怎么设置线程和并发数
域名网站 tk域名注册 北京服务器租用 二级域名申请 注册cn域名 greengeeks cybermonday 东莞电信局 免费申请网页 香港服务器99idc pw域名 z.com 河南服务器 cpanel空间 数字域名 工作站服务器 域名和空间 怎么建立邮箱 空间登陆首页 东莞主机托管 更多