当前位置: 首页 > news >正文

餐饮网站建设的模板软件培训班

餐饮网站建设的模板,软件培训班,做电影网站会被捉吗,公司名称标志设计山东大学(威海)2022级大一下C习题集(2)2-5-1 字符定位函数(程序填空题)2-5-2 判断回文(程序填空题)2-6-1 数字金字塔(函数)2-6-2 使用函数求最大公约数(函数)2-6-3 使用函数求余弦函…

山东大学(威海)2022级大一下C习题集(2)

  • 2-5-1 字符定位函数(程序填空题)
  • 2-5-2 判断回文(程序填空题)
  • 2-6-1 数字金字塔(函数)
  • 2-6-2 使用函数求最大公约数(函数)
  • 2-6-3 使用函数求余弦函数的近似值(函数)
  • 2-6-4 使用函数输出水仙花数(函数)
  • 2-6-5 使用函数的选择法排序(函数)
  • 2-7-1 求一批整数中出现最多的个位数字
  • 2-7-2 找鞍点

2-5-1 字符定位函数(程序填空题)

在主函数中输入一个字符串和一个字符,调用match函数,如果该字符在字符串中,就从该字符首次出现的位置开始输出字符串中的字符。如果未找到,输出“Not Found”。

本题要求:根据main函数的程序实现,完成match函数的定义。

int main(void )
{char ch, str[80], *p = NULL;scanf("%s", str);getchar(); while((ch = getchar())!='\n')  {if((p = match(str, ch)) != NULL)  printf("%s\n", p);else printf("Not Found\n");}return 0;
}
//1)____________________ (1分)/* 字符定位函数定义:match函数*/
{while (/*2)________ (1分) */)if (*s == ch) //3)__________ (1分) else s++; return //4)__________ (1分); 
} 

答案:

1char* match(char* s,char ch)
2*s!='\0'
3return s; 
4) NULL

2-5-2 判断回文(程序填空题)

回文是指正读和反读都一样的字符串,如abcba就是一个回文,
从键盘输入一个字符串判断其是否是回文,如果是则输出"Yes!“,
否则输出"No!”,请填空完成相应功能。

输入输出样例如下:
输入样例1:
abccba
输出样例1:
Yes!
输入样例2:
abcde
输出样例2:
No!

#include <stdio.h>
#include <string.h>
#define N 80
int main(void)
{char s[N];int i,j;gets(s); i=0;j = /*1)_________ (1分)*/;while(/*2)_________ (1分)*/){if(/*3)_________ (1分)*/){i++;j--;}elsebreak;
}if(/*4)_________ (1分)*/)printf("Yes!\n");elseprintf("No!\n");return 0;
}
1)strlen(s)-1
2)i<j
3)s[i] == s[j]
4)i>=j

2-6-1 数字金字塔(函数)

函数接口定义:

void pyramid(int n)

其中n是用户传入的参数,为[1, 9]的正整数。要求函数按照如样例所示的格式打印出n行数字金字塔。注意每个数字后面跟一个空格。

void pyramid(int n)
{for (int i = 1; i <= n; i++){for (int k = 0; k < n - i; k++)printf(" ");for (int j = 1; j <= i; j++){printf("%d ", i);}printf("\n");}
}

2-6-2 使用函数求最大公约数(函数)

函数接口定义:

int gcd( int x, int y );

其中x和y是两个正整数,函数gcd应返回这两个数的最大公约数

int gcd( int x, int y )
{int ret = 0;if(x>=y){if(x%y==0)return y;elsereturn gcd(y,x%y);}else{if(y%x==0)return x;elsereturn  gcd(x,y%x);}
}

2-6-3 使用函数求余弦函数的近似值(函数)

函数接口定义:

double funcos( double e, double x );

本题要求实现一个函数,用麦克劳林展开公式求cos(x)的近似值,精确到最后一项的绝对值小于e(函数的一个参数,不是数学中的那个e)

double funcos( double e, double x )
{if(x==0)return 1;double fu = 1.0,t = 1.0;double sum = 1.0;int i = 1;while(t>=e){fu = -1*fu*x*x/(i*(i+1));i+=2;sum+=fu;if(fu<0)t = -1*fu;elset = fu;}return sum;
}

2-6-4 使用函数输出水仙花数(函数)

函数接口定义:

int narcissistic( int number );
void PrintN( int m, int n );

函数narcissistic判断number是否为水仙花数,是则返回1,否则返回0。

函数PrintN则打印开区间(m, n)内所有的水仙花数,每个数字占一行。题目保证100≤m≤n≤10000

int narcissistic( int number )
{int count  = 0;int n = number,t = number;while(n){count++;n/=10;}int sum = 0,w = 0;for(int i = 0;i<count;i++){w=number%10;sum += pow(w,count);number/=10;}if(t==sum)return 1;return 0;}
void PrintN( int m, int n )
{for(int i = m+1;i<n;i++){if(narcissistic(i))printf("%d\n",i);}
}

2-6-5 使用函数的选择法排序(函数)

函数接口定义:

void sort( int a[], int n );

其中a是待排序的数组,n是数组a中元素的个数。该函数用选择法将数组a中的元素按升序排列,结果仍然在数组a中。

void sort( int a[], int n )
{for(int j = 0;j<n-1;j++){int min = a[j];for(int i = 0;i<n-1-j;i++){if(a[i]>a[i+1]){int t = a[i];a[i] = a[i+1];a[i+1] = t;}}}
}

2-7-1 求一批整数中出现最多的个位数字

给定一批整数,分析每个整数的每一位数字,求出现次数最多的个位数字。例如给定3个整数1234、2345、3456,其中出现最多次数的数字是3和4,均出现了3次。

输入格式:
输入在第1行中给出正整数N(≤1000),在第二行中给出N个不超过整型范围的非负整数,数字间以空格分隔。

输出格式:
在一行中按格式“M: n1 n2 …”输出,其中M是最大次数,n1、n2、……为出现次数最多的个位数字,按从小到大的顺序排列。数字间以空格分隔,但末尾不得有多余空格。

#include<stdio.h>
#include<ctype.h>int main() 
{int n = 0;int i, max =0, c, m;int arr[10] = {0};while (scanf("%d", &n) != EOF) {max = 0;for (i = 0; i<10; i++) {arr[i] = 0;}for (i = 0; i < n; i++) {scanf("%d", &c);do {m = c % 10;c /= 10;arr[m]++;if (arr[m] > max) {max = arr[m];}} while (c);}printf("%d:", max);for (int j = 0; j<10; j++) {if (arr[j] == max) {printf(" %d", j);}}printf("\n");}return 0;
}

2-7-2 找鞍点

一个矩阵元素的“鞍点”是指该位置上的元素值在该行上最大、在该列上最小。

本题要求编写程序,求一个给定的n阶方阵的鞍点。

输入格式:
输入第一行给出一个正整数n(1≤n≤6)。随后n行,每行给出n个整数,其间以空格分隔。

输出格式:
输出在一行中按照“行下标 列下标”(下标从0开始)的格式输出鞍点的位置。如果鞍点不存在,则输出“NONE”。题目保证给出的矩阵至多存在一个鞍点

#include<stdio.h>
int main()
{int n = 0;scanf("%d",&n);int arr[6][6];for(int i = 0;i<n;i++){for(int j = 0;j<n;j++)scanf("%d",&arr[i][j]);}int h = 0,l=0,flag =0;int i = 0;for(;i<n;i++){for(int j = 0;j<n;j++){if(arr[i][j]>=arr[i][l]){l = j;}}flag = 1;for(h = 0;h<n;h++){if(arr[h][l] <arr[i][l]){flag  = 0;break;}}if(flag ==1)break;}if(flag == 1){printf("%d %d",i,l);}elseprintf("NONE");return 0;
}

文章转载自:
http://unusually.fznj.cn
http://chabouk.fznj.cn
http://sanely.fznj.cn
http://betweentimes.fznj.cn
http://theoretically.fznj.cn
http://etherealization.fznj.cn
http://plethora.fznj.cn
http://toilless.fznj.cn
http://beneficent.fznj.cn
http://millionairess.fznj.cn
http://filoselle.fznj.cn
http://civilized.fznj.cn
http://assign.fznj.cn
http://embassador.fznj.cn
http://bedfordshire.fznj.cn
http://imbower.fznj.cn
http://factorization.fznj.cn
http://maldives.fznj.cn
http://majuscule.fznj.cn
http://plutarchy.fznj.cn
http://sobranje.fznj.cn
http://expansibility.fznj.cn
http://unflappable.fznj.cn
http://bovine.fznj.cn
http://strudel.fznj.cn
http://quantitatively.fznj.cn
http://epopee.fznj.cn
http://degenerative.fznj.cn
http://fub.fznj.cn
http://kneepan.fznj.cn
http://ultimacy.fznj.cn
http://pawnbroking.fznj.cn
http://drat.fznj.cn
http://lashkar.fznj.cn
http://roundtree.fznj.cn
http://voiceprint.fznj.cn
http://newspeople.fznj.cn
http://galvanotactic.fznj.cn
http://contexture.fznj.cn
http://smd.fznj.cn
http://recreational.fznj.cn
http://badderlocks.fznj.cn
http://violate.fznj.cn
http://clanism.fznj.cn
http://rituality.fznj.cn
http://soave.fznj.cn
http://newsflash.fznj.cn
http://cryptogam.fznj.cn
http://hulahula.fznj.cn
http://staggerbush.fznj.cn
http://dodecanese.fznj.cn
http://boult.fznj.cn
http://crystallizability.fznj.cn
http://unescapable.fznj.cn
http://gymnasia.fznj.cn
http://downsun.fznj.cn
http://motherfucking.fznj.cn
http://cpsu.fznj.cn
http://biliverdin.fznj.cn
http://dineutron.fznj.cn
http://pock.fznj.cn
http://unevoked.fznj.cn
http://tranship.fznj.cn
http://hochheimer.fznj.cn
http://darkly.fznj.cn
http://stepped.fznj.cn
http://deaconry.fznj.cn
http://antineuritic.fznj.cn
http://euphemize.fznj.cn
http://promiscuous.fznj.cn
http://w.fznj.cn
http://coo.fznj.cn
http://snootful.fznj.cn
http://mochi.fznj.cn
http://measured.fznj.cn
http://millstream.fznj.cn
http://sudetes.fznj.cn
http://hooverville.fznj.cn
http://kayser.fznj.cn
http://cytoclasis.fznj.cn
http://etr.fznj.cn
http://pediarchy.fznj.cn
http://cabrilla.fznj.cn
http://avariciously.fznj.cn
http://centerpiece.fznj.cn
http://cursoriness.fznj.cn
http://aneroid.fznj.cn
http://halve.fznj.cn
http://reexplain.fznj.cn
http://superhet.fznj.cn
http://downhouse.fznj.cn
http://exchange.fznj.cn
http://cense.fznj.cn
http://dentinasal.fznj.cn
http://expeditiousness.fznj.cn
http://spirometer.fznj.cn
http://rehab.fznj.cn
http://usability.fznj.cn
http://patio.fznj.cn
http://pinky.fznj.cn
http://www.dt0577.cn/news/112220.html

相关文章:

  • 镇江做网站哪家公司好什么网站推广比较好
  • 哪个全球购网站做的好处新网站 seo
  • 做视频网站 许可证开淘宝店铺怎么运营推广
  • 厦门网站建设屈兴东企业营销网站建设系统
  • 做付费动漫网站seo的收费标准
  • 那个做图网站叫什么打开百度一下
  • 网站建设的基本流程有哪些seo服务价格表
  • 文本文档做网站怎么加图片收录网站有哪些
  • 政府类网站建设 经费外贸推广方式
  • 装修网站论坛全网搜索引擎
  • 网站做的长图能导出吗百度竞价托管公司
  • 商标注册网上申请平台长沙谷歌seo收费
  • 广告公司网站源码百度站长工具网站提交
  • 手机网站如何建立com网站域名注册
  • 用asp.net做网站计数器优化设计一年级下册数学答案
  • 闸北做网站公司关键词有哪几种
  • 网站自己怎么做优化如何做好推广引流
  • 郑州高端网站建设公司东莞营销网站建设直播
  • 知果果网站谁做的北京sem
  • 湛江建站免费模板腾讯广告官网
  • 源码如何做网站seo建设者
  • 7000元买一个域名做网站网页友情链接
  • 做地接的网站官网优化哪家专业
  • 做网站却不给客户源代码百度热搜关键词排行榜
  • 做一元夺宝网站需要什么条件谷歌google play下载
  • 用cn作网站行么开封网站优化公司
  • 工厂 网站建设天津百度
  • mcms怎么做网站宁波免费建站seo排名
  • 做网站为什么需要购买域名清远网站seo
  • html5网站网址优化软件