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; }

VoLLcloud:超便宜香港CMI大带宽vps-三网CMI直连-年付四免服务-低至4刀/月-奈飞

vollcloud LLC创立于2020年,是一家以互联网基础业务服务为主的 技术型企业,运营全球数据中心业务。致力于全球服务器租用、托管及云计算、DDOS安 全防护、数据实时存储、 高防服务器加速、域名、智能高防服务器、网络安全服务解决方案等领域的智 能化、规范化的体验服务。所有购买年付产品免费更换香港原生IP(支持解锁奈飞),商家承诺,支持3天内无条件退款(原路退回)!点击进入:vollclo...

SugarHosts新增Windows云服务器sugarhosts六折无限流量云服务器六折优惠

SugarHosts糖果主机商我们较早的站长们肯定是熟悉的,早年是提供虚拟主机起家的,如今一直还在提供虚拟主机,后来也有增加云服务器、独立服务器等。数据中心涵盖美国、德国、香港等。我们要知道大部分的海外主机商都只提供Linux系统云服务器。今天,糖果主机有新增SugarHosts夏季六折的优惠,以及新品Windows云服务器/云VPS上线。SugarHosts Windows系统云服务器有区分限制...

819云互联 香港 日本 美国 2核4G 18元 8核8G 39元 免费空间 免费CDN 香港 E3 16G 20M 230元/月

819云互联是海外领先的互联网业务平台服务提供商。专注为用户提供低价高性能云计算产品,致力于云计算应用的易用性开发,并引导云计算在国内普及。目前平台研发以及运营云服务基础设施服务平台(IaaS),面向全球客户提供基于云计算的IT解决方案与客户服务,拥有丰富的海外资源、香港,日本,美国等各国优质的IDC资源。官方网站:https://www.819yun.com香港特价物理服务器:地区CPU内存带宽...

c语言程序设计题库为你推荐
在线年龄查询器怎样喂熊熊?创业好项目论坛现在挣钱太难了、大家有什么好项目linux操作系统好吗linux系统好不好学??金山铁路最新时刻表金山北至上虞北高铁时间表计算机编程基础计算机编程需要有哪些基础软件测试工程师待遇软件测试工程师待遇好吗微服务网关微服务网页打不开是什么原因微服务网关如何使用 spring boot&47;spring cloud 实现微服务应用大数据的分类数据类型的种类清除地址栏怎样清除地址栏上面的网址
猫咪永久域名收藏地址 香港加速器 美国主机推荐 windows2003iso 免费网站申请 php空间申请 免费个人空间 如何注册阿里云邮箱 免费私人服务器 美国盐湖城 xuni 免费php空间 成都主机托管 免费网络空间 国外免费网盘 镇江高防服务器 websitepanel 中美互联网论坛 linux服务器系统 德国代理 更多