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

CloudCone(12.95美元/月CN2 GT线路,KVM架构1 Gbps带宽

整理一下CloudCone商家之前推送的闪购VPS云服务器产品,数量有限,活动推出可能很快机器就售罄了,有需要美国便宜VPS云服务器的朋友可以关注一下。CloudCone怎么样?CloudCone服务器好不好?CloudCone值不值得购买?CloudCone是一家成立于2017年的美国服务器提供商,国外实力大厂,自己开发的主机系统面板,CloudCone主要销售美国洛杉矶云服务器产品,优势特点是...

raksmart:全新cloud云服务器系列测评,告诉你raksmart新产品效果好不好

2021年6月底,raksmart开发出来的新产品“cloud-云服务器”正式上线对外售卖,当前只有美国硅谷机房(或许以后会有其他数据中心加入)可供选择。或许你会问raksmart云服务器怎么样啊、raksm云服务器好不好、网络速度快不好之类的废话(不实测的话),本着主机测评趟雷、大家受益的原则,先开一个给大家测评一下!官方网站:https://www.raksmart.com云服务器的说明:底层...

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

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

c语言程序设计题库为你推荐
智能加速加速器是干什么的?office软件包office软件包括哪几个部分qq空间维护QQ空间维护是什么情况?怎么解除?垃圾文件清理bat一键清理系统垃圾文件的批处理qq空间个性域名QQ空间里什么是 空间个性域名bt4破解教程请教BT4光盘版的教程微信语音在哪个文件夹微信语音在哪个文件夹 微信语音导出及amr格式转换vs2005快捷键VS2005的快捷方式是哪个文件啊?云图好看吗云图这部电影好看吗音响解码大家好,音响锁住了怎么解锁?
山东vps 美国主机排名 香港bgp机房 a2hosting locvps bbr 256m内存 wavecom 万网优惠券 网站挂马检测工具 免费个人空间申请 卡巴斯基官方免费版 建立邮箱 东莞服务器 独享主机 云销售系统 葫芦机 美国asp空间 建站论坛 服务器操作系统 更多