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

RAKsmartCloud服务器,可自定义配置月$7.59

RAKsmart商家一直以来在独立服务器、站群服务器和G口和10G口大端口流量服务器上下功夫比较大,但是在VPS主机业务上仅仅是顺带,尤其是我们看到大部分主流商家都做云服务器,而RAKsmart商家终于开始做云服务器,这次试探性的新增美国硅谷机房一个方案。月付7.59美元起,支持自定义配置,KVM虚拟化,美国硅谷机房,VPC网络/经典网络,大陆优化/精品网线路,支持Linux或者Windows操作...

ZJI全新上架香港站群服务器,4C段238个IP月付1400元起

ZJI本月新上线了香港葵湾机房站群服务器,提供4个C段238个IPv4,支持使用8折优惠码,优惠后最低每月1400元起。ZJI是原Wordpress圈知名主机商家:维翔主机,成立于2011年,2018年9月更名为ZJI,提供中国香港、台湾、日本、美国独立服务器(自营/数据中心直营)租用及VDS、虚拟主机空间、域名注册等业务,所选数据中心均为国内普遍访问速度不错的机房。葵湾二型(4C站群)CPU:I...

cera:秋季美国便宜VPS促销,低至24/月起,多款VPS配置,自带免费Windows

介绍:819云怎么样?819云创办于2019,由一家从2017年开始从业的idc行业商家创办,主要从事云服务器,和物理机器819云—-带来了9月最新的秋季便宜vps促销活动,一共4款便宜vps,从2~32G内存,支持Windows系统,…高速建站的美国vps位于洛杉矶cera机房,服务器接入1Gbps带宽,采用魔方管理系统,适合新手玩耍!官方网站:https://www.8...

c语言程序设计题库为你推荐
windows7正版验证如何在微软网站验证Win7系统是否正版的方法java学习思维导图优秀好用的免费流程图与思维导图绘制工具有哪些,最好mac下和windows下都可以用。qq空间个性域名Qq空间的个性域名是什么意思。微软将停止支持32位Win10系统微软即将停止支持当前操作系统,如果不升级会怎么样北漂论坛北漂族的艰辛主要体现在哪些方面?创业好项目论坛谁能提供点真实可靠的,网络创业赚钱项目?慕课网址如何加入慕课学习课程?微软永久关闭实体店微软windows10易升怎么关闭新浪短网址链接生成新浪微博怎么发图文带短连接连接到自己的网站?湖北健康码转码申请坐火车途经疫区健康码会变吗?
政务和公益机构域名注册管理中心 国外免费vps 3322免费域名 互联网域名管理办法 securitycenter 缓存服务器 国外空间服务商 一点优惠网 微软服务器操作系统 shopex主机 联通网站 太原联通测速 服务器维护 免费asp空间申请 cdn网站加速 webmin zencart安装 ping值 网络安装 回程 更多