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

[黑五]ProfitServer新加坡/德国/荷兰/西班牙VPS五折,不限流量KVM月付2.88美元起

ProfitServer已开启了黑色星期五的促销活动,一直到本月底,商家新加坡、荷兰、德国和西班牙机房VPS直接5折,无码直购最低每月2.88美元起,不限制流量,提供IPv4+IPv6。这是一家始于2003年的俄罗斯主机商,提供虚拟主机、VPS、独立服务器、SSL证书、域名等产品,可选数据中心包括俄罗斯、法国、荷兰、美国、新加坡、拉脱维亚、捷克、保加利亚等多个国家和地区。我们随便以一个数据中心为例...

香港服务器促销:香港华为云混合服务器、高防服务器首月半价,普通110M大带宽服务器月付799,付5用6,付10用13

博鳌云是一家以海外互联网基础业务为主的高新技术企业,运营全球高品质数据中心业务。自2008年开始为用户提供服务,距今11年,在国人商家中来说非常老牌。致力于为中国用户提供域名注册(国外接口)、免费虚拟主机、香港虚拟主机、VPS云主机和香港、台湾、马来西亚等地服务器租用服务,各类网络应用解決方案等领域的专业网络数据服务。商家支持支付宝、微信、银行转账等付款方式。目前香港有一款特价独立服务器正在促销,...

百纵科技(19元/月),美国洛杉矶10G防御服务器/洛杉矶C3机房 带金盾高防

百纵科技官网:https://www.baizon.cn/百纵科技:美国云服务器活动重磅来袭,洛杉矶C3机房 带金盾高防,会员后台可自助管理防火墙,添加黑白名单 CC策略开启低中高.CPU全系列E52680v3 DDR4内存 三星固态盘列阵。另有高防清洗!美国洛杉矶 CN2 云服务器CPU内存带宽数据盘防御价格1H1G10M10G10G19元/月 购买地址2H1G10M10G10G29元/月 购买...

c语言程序设计题库为你推荐
stm32视频教程求STM32从基础到应用的全套教程qq空间个性域名Qq空间的个性域名是什么意思。圣诞节网页制作如何制作圣诞节贺卡微软将停止支持32位Win10系统win10提示系统安装错误怎么解决magento模板magento系统缩略图大小在哪里修改?印象城市游戏论坛凯撒大帝3怎么建造好一个城市电梯物联网平台电梯物联网技术运用到电梯的远程监控上,能实现什么作用?2020带来好运的微信头像女人带来好运的微信网名是什么?flv转换aviflv怎么转换成avi无法清除dns缓存Windows无法清除DNS缓存
域名城 万网域名代理 免费域名申请 域名解析服务器 花生壳免费域名 免费申请域名和空间 圣迭戈 网站保姆 seovip 青果网 mysql主机 e蜗牛 河南移动m值兑换 如何安装服务器系统 美国独立日 什么是web服务器 可外链的相册 空间服务器 阿里云邮箱个人版 杭州电信 更多