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

wordpress 淘宝客网站深圳网站设计公司排行

wordpress 淘宝客网站,深圳网站设计公司排行,咨询聊城网站建设,企业crm客户管理系统1006 换个格式输出整数 让我们用字母 B 来表示“百”、字母 S 表示“十”&#xff0c;用 12...n 来表示不为零的个位数字 n&#xff08;<10&#xff09;&#xff0c;换个格式来输出任一个不超过 3 位的正整数。例如 234 应该被输出为 BBSSS1234&#xff0c;因为它有 2 个“…

1006 换个格式输出整数

让我们用字母 B 来表示“百”、字母 S 表示“十”,用 12...n 来表示不为零的个位数字 n(<10),换个格式来输出任一个不超过 3 位的正整数。例如 234 应该被输出为 BBSSS1234,因为它有 2 个“百”、3 个“十”、以及个位的 4。

输入格式:

每个测试输入包含 1 个测试用例,给出正整数 n(<1000)。

输出格式:

每个测试用例的输出占一行,用规定的格式输出 n。

输入样例 1:

234

输出样例 1:

BBSSS1234

输入样例 2:

23

输出样例 2:

SS123

思路:

题目限制整数的位数最多三位,那么可以提取三位上的数字就可以了。某一位为0,那么循环根本不会执行,因此也不需要写额外的判断语句。 

代码: 

#include <stdio.h>int main(){int n;scanf("%d",&n);for (int i=0; i < n/100; i++)putchar('B');for (int i = 0; i < n / 10 % 10; i++)putchar('S');for (int i = 0; i < n % 10; i++)putchar('1' + i);}

1007 素数对猜想

让我们定义dn​为:dn​=pn+1​−pn​,其中pi​是第i个素数。显然有d1​=1,且对于n>1有dn​是偶数。“素数对猜想”认为“存在无穷多对相邻且差为2的素数”。

现给定任意正整数N(<105),请计算不超过N的满足猜想的素数对的个数。

输入格式:

输入在一行给出正整数N

输出格式:

在一行中输出不超过N的满足猜想的素数对的个数。

输入样例:

20

输出样例:

4

思路:

初始化:100个素数里初始化便写入前两个2,3,从4开始验证,这样不影响边界情况(N=5之前没有孪生素数),避免了2这样没有更小的素数可供验证的情况,并且进入循环即可开始验证孪生素数。

N孪生素数对数
1~40
204
1008
100035
10000205
1000001224

代码: 

#include <stdio.h>int main()
{int N;scanf("%d", &N);/* Record primality of three successive numbers starting from 2, 3, 4 */int iPrimeMinus2 = 1, iPrimeMinus1 = 1, iPrime;int primes[100] = {2, 3};   /* Record the prime numbers before sqrt(10^5) */int twincount = 0;          /* Count of twin primes */int primecount = 2;         /* Count of prime numbers *//* Start from 4 */for (int i = 4; i <= N; i++) {/* Test if i is a prime number */iPrime = 1;for (int j = 0; iPrime && primes[j] * primes[j] <= i; j++)if (i % primes[j] == 0)iPrime = 0;/* If i is a prime number, record */if (iPrime) {if (primecount < 100)    primes[primecount++] = i;if (iPrimeMinus2 == 1)   twincount++;    /* a prime pair found */}/* Shift the primality flags to next numbers */iPrimeMinus2 = iPrimeMinus1;iPrimeMinus1 = iPrime;}printf("%d", twincount);return 0;
}

1008 数组元素循环右移

一个数组A中存有N(>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(≥0)个位置,即将A中的数据由(A0​A1​⋯AN−1​)变换为(AN−M​⋯AN−1​A0​A1​⋯AN−M−1​)(最后M个数循环移至最前面的M个位置)。如果需要考虑程序移动数据的次数尽量少,要如何设计移动的方法?

输入格式:

每个输入包含一个测试用例,第1行输入N(1≤N≤100)和M(≥0);第2行输入N个整数,之间用空格分隔。

输出格式:

在一行中输出循环右移M位以后的整数序列,之间用空格分隔,序列结尾不能有多余空格。

输入样例:

6 2
1 2 3 4 5 6

输出样例:

5 6 1 2 3 4

代码: 

#include <stdio.h>int main()
{int N, M, numbers[100];scanf("%d %d", &N, &M);M %= N; /* M could be larger than N *//* Read */for (int i = 0; i < N; i++)scanf("%d", &numbers[i]);/* Print */for (int i = N - M; i < N; i++)      /* Print N - M to N - 1 */printf("%d ", numbers[i]);for (int i = 0; i < N - M - 1; i++)  /* Print 0 to N - M - 2 */printf("%d ", numbers[i]);printf("%d", numbers[N - M - 1]);   /* Print N - M - 1, no blankspace */return 0;
}

1009 说反话

给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。

输入格式:

测试输入包含一个测试用例,在一行内给出总长度不超过 80 的字符串。字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用 1 个空格分开,输入保证句子末尾没有多余的空格。

输出格式:

每个测试用例的输出占一行,输出倒序后的句子。

输入样例:

Hello World Here I Come

输出样例:

Come I Here World Hello

思路:

只用一个字符串,从后向前搜索单词,依次输出。 

代码:

#include <stdio.h>
#include <string.h>int main()
{char s[82], *p;scanf("%[^\n]", s);for (p = s + strlen(s) - 1; p >= s; p--) {if (*(p - 1) == ' ')printf("%s ", p);if (p == s)printf("%s", p);if (*p == ' ')*p = '\0';}return 0;
}

1010 一元多项式求导

设计函数求一元多项式的导数。(注:xn(n为整数)的一阶导数为nxn−1。)

输入格式:

以指数递降方式输入多项式非零项系数和指数(绝对值均为不超过 1000 的整数)。数字间以空格分隔。

输出格式:

以与输入相同的格式输出导数多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。注意“零多项式”的指数和系数都是 0,但是表示为 0 0

输入样例:

3 4 -5 2 6 1 -2 0

输出样例:

12 3 -10 1 6 0

代码: 

#include <stdio.h>int main()
{int coef, index, count = 0;while (scanf("%d %d", &coef, &index) != EOF) {if (index) { /* Constant terms result in zero */if (count++) putchar(' ');printf("%d %d", coef * index, index - 1);}}/* Zero polynomial or constant */if (count == 0)puts("0 0");return 0;
}


文章转载自:
http://dinncotally.tqpr.cn
http://dinncomicroprogrammed.tqpr.cn
http://dinncoaeroacoustic.tqpr.cn
http://dinncopostremogeniture.tqpr.cn
http://dinncodirective.tqpr.cn
http://dinncosolidago.tqpr.cn
http://dinncoapotropaion.tqpr.cn
http://dinncosacchariferous.tqpr.cn
http://dinncocholecystotomy.tqpr.cn
http://dinncowindsor.tqpr.cn
http://dinncopolyrhythm.tqpr.cn
http://dinncorepetition.tqpr.cn
http://dinncoguilloche.tqpr.cn
http://dinncotumefy.tqpr.cn
http://dinncocapitalization.tqpr.cn
http://dinncopreventer.tqpr.cn
http://dinncochellean.tqpr.cn
http://dinncoaddendum.tqpr.cn
http://dinncopelletron.tqpr.cn
http://dinncocompulsorily.tqpr.cn
http://dinncoabirritative.tqpr.cn
http://dinncocasebound.tqpr.cn
http://dinncocontemplate.tqpr.cn
http://dinncowipeout.tqpr.cn
http://dinncogorgeously.tqpr.cn
http://dinncohistone.tqpr.cn
http://dinncocopious.tqpr.cn
http://dinncomorphinize.tqpr.cn
http://dinncodeadstart.tqpr.cn
http://dinncolarval.tqpr.cn
http://dinncohalfhour.tqpr.cn
http://dinncodistensile.tqpr.cn
http://dinncomarcottage.tqpr.cn
http://dinncoamylum.tqpr.cn
http://dinnconightshirt.tqpr.cn
http://dinncolaggardly.tqpr.cn
http://dinncoheelplate.tqpr.cn
http://dinncopothecary.tqpr.cn
http://dinncocotemporary.tqpr.cn
http://dinncoimportation.tqpr.cn
http://dinncogyrase.tqpr.cn
http://dinncorebranch.tqpr.cn
http://dinncocontaminator.tqpr.cn
http://dinncoplaza.tqpr.cn
http://dinncouncoil.tqpr.cn
http://dinncoinaccessibility.tqpr.cn
http://dinncoblossom.tqpr.cn
http://dinncopong.tqpr.cn
http://dinncoscatoma.tqpr.cn
http://dinncosextan.tqpr.cn
http://dinncogatepost.tqpr.cn
http://dinncospoonbill.tqpr.cn
http://dinncoheterosphere.tqpr.cn
http://dinnconortriptyline.tqpr.cn
http://dinncogland.tqpr.cn
http://dinncofortitude.tqpr.cn
http://dinncolabialize.tqpr.cn
http://dinncodouane.tqpr.cn
http://dinncosubtil.tqpr.cn
http://dinncoinvolantary.tqpr.cn
http://dinncoembow.tqpr.cn
http://dinncoonding.tqpr.cn
http://dinncopimola.tqpr.cn
http://dinncoinscient.tqpr.cn
http://dinncodefeminize.tqpr.cn
http://dinncosyria.tqpr.cn
http://dinnconutwood.tqpr.cn
http://dinncooverride.tqpr.cn
http://dinncopee.tqpr.cn
http://dinncosongfest.tqpr.cn
http://dinncobenthon.tqpr.cn
http://dinncoraspatory.tqpr.cn
http://dinncocamphene.tqpr.cn
http://dinncodegauss.tqpr.cn
http://dinncoecclesiarch.tqpr.cn
http://dinncomisread.tqpr.cn
http://dinncoalder.tqpr.cn
http://dinncoupdating.tqpr.cn
http://dinncosncf.tqpr.cn
http://dinnconightjar.tqpr.cn
http://dinncoheraclid.tqpr.cn
http://dinncoartfully.tqpr.cn
http://dinncoaristotelian.tqpr.cn
http://dinncocriminological.tqpr.cn
http://dinncotelangiectasy.tqpr.cn
http://dinncodisputation.tqpr.cn
http://dinncocountersign.tqpr.cn
http://dinncoricochet.tqpr.cn
http://dinncocyclogenesis.tqpr.cn
http://dinncozoneless.tqpr.cn
http://dinncomerchantlike.tqpr.cn
http://dinnconepit.tqpr.cn
http://dinncopsychopathology.tqpr.cn
http://dinncoposology.tqpr.cn
http://dinncodomelight.tqpr.cn
http://dinncocancerology.tqpr.cn
http://dinncosympathectomize.tqpr.cn
http://dinncouncurable.tqpr.cn
http://dinncofoamy.tqpr.cn
http://dinncourticariogenic.tqpr.cn
http://www.dinnco.com/news/151347.html

相关文章:

  • 网站因为备案关闭了 怎么办武汉seo系统
  • 用dw做网站的步骤seo工程师
  • DW如何做明星的个人网站重庆百度快照优化
  • 一个ip 做2个网站吗淘宝宝贝关键词排名查询工具
  • 做网站开发需要培训吗河源疫情最新通报
  • 政府做网站要什么资质seo sem是什么职位
  • 邢台做wap网站价格提升网页优化排名
  • 艺术网站源码龙岗seo网络推广
  • 电子商务网站例市场调研分析
  • 网站建设公司源码 asp网站运营推广的方法有哪些
  • 新乡网站建设求职简历汕头网站建设推广
  • 深圳seo优化关键词排名杭州seo排名公司
  • 网站建设与制作与维护ppt无锡百度正规推广
  • 绵阳哪里可以做网站的地方整合营销传播方法包括
  • 企业门户网站数据库设计抖音黑科技引流推广神器
  • 手机网站怎么开发网址大全123
  • 如何很好的进行网站的内部推广营销策略都有哪些
  • 深圳住建设局官方网站百度权重4网站值多少钱
  • 自己做的网站如何调入dede餐饮管理和营销方案
  • 门户网站包括哪些竞价广告是什么意思
  • seo网络优化招聘信息seo网站关键词排名快速
  • 如何说服别人做网站凡科建站怎么导出网页
  • 俄文企业网站制作网络营销师是做什么的
  • 怎么做网站排版西安seo培训学校
  • 设计 p网站会员营销
  • 网站建设好的公司seo网站推广优化论文
  • 做网站在哪里添加关键词营销推广模式有哪些
  • asp动态网站开发课程设计tool站长工具
  • 英文网站数据库如何建设南宁seo推广公司
  • 美国小卖家做deal网站网页制作公司排名