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

怎样在凡科免费做网站新疆头条今日头条新闻

怎样在凡科免费做网站,新疆头条今日头条新闻,自用电脑做网站,石家庄企业建站哪家好一确定字符串是否包含唯一字符 1.1涉及知识点 c的输入输出语法 cin>>s; cout<<"NO"; 如何定义字符串 切记&#xff1a;在[]中必须加数字——字符串最大长度&#xff0c;不然编译不通过 char s[101]; 如何获取字符串长度 char s[101];cin>>s;i…

一确定字符串是否包含唯一字符

1.1涉及知识点 

c++的输入输出语法

cin>>s;
cout<<"NO";

如何定义字符串

切记:在[]中必须加数字——字符串最大长度,不然编译不通过

char s[101];

如何获取字符串长度

  char s[101];cin>>s;int n=strlen(s);

1.2题解

思路

先定义一个字符数组,再利用双重for循环将字符一个个比较,如果相等就输出NO,提前结束循环

代码

#include <iostream>
#include<cstring>
using namespace std;
int main()
{// 请在此输入您的代码char s[101];cin>>s;int i=0;int j=0;int n=strlen(s);for(i;i<n;i++){for(j=i+1;j<n;j++){if(s[i]==s[j]){cout<<"NO";return 0;}}}cout<<"YES";return 0;
}

二、确定字符串是否是另一个的排列

2.1涉及知识点 

  1. 字符串排序函数sort

sort函数用于C++中,对给定区间所有元素进行排序。头文件是#include <algorithm>。

函数原型如下

sort(first_pointer, first_pointer + n, cmp)


此函数有3个参数:

第一个参数是要排序的数组的起始地址。
第二个参数是结束的地址(最后一位要排序的地址的下一地址)
第三个参数是排序的方法,可以是从大到小也可是从小到大,还可以不写第三个参数,此时默认的排序方法是从小到大排序。
如果要改为从大到小排序,需要加一个函数compare

  1. 字符串比较函数strcmp

strcmp 函数从两个字符串的开头开始,逐个字符地进行比较。它使用ASCII值来比较对应的字符

int strcmp(const char *str1, const char *str2);
  • 如果 str1 小于 str2,则返回值小于 0。
  • 如果 str1 大于 str2,则返回值大于 0。
  • 如果 str1 和 str2 相等,则返回 0

2.2题解

思路

先将两字符进行排序(使用sort函数),在进行两字符串的比较(利用strcmp函数)

代码

#include <iostream>
#include<cstring>
#include <algorithm>
using namespace std;
int main()
{// 请在此输入您的代码char str1[101];char str2[101];cin>>str1;cin>>str2;int n=strlen(str1);int m=strlen(str2);if(n==m){sort(str1,str1+n);sort(str2,str2+m);if(strcmp(str1,str2)!=0){cout<<"NO";return 0;}}else{cout<<"NO";return 0;}cout<<"YES";return 0;
}


文章转载自:
http://wildwind.rpwm.cn
http://shelleyan.rpwm.cn
http://oao.rpwm.cn
http://coniroster.rpwm.cn
http://harpoon.rpwm.cn
http://nightclothes.rpwm.cn
http://cybernetician.rpwm.cn
http://pest.rpwm.cn
http://nosocomial.rpwm.cn
http://nasion.rpwm.cn
http://caulis.rpwm.cn
http://whenas.rpwm.cn
http://battleship.rpwm.cn
http://excursus.rpwm.cn
http://ionogen.rpwm.cn
http://excrescency.rpwm.cn
http://duumvir.rpwm.cn
http://eobiont.rpwm.cn
http://zagreus.rpwm.cn
http://motorist.rpwm.cn
http://fulgurant.rpwm.cn
http://overburdensome.rpwm.cn
http://unrighteousness.rpwm.cn
http://amino.rpwm.cn
http://californian.rpwm.cn
http://sextus.rpwm.cn
http://radiopacity.rpwm.cn
http://smaltite.rpwm.cn
http://emarcid.rpwm.cn
http://ail.rpwm.cn
http://tuna.rpwm.cn
http://tektite.rpwm.cn
http://wellsian.rpwm.cn
http://mimic.rpwm.cn
http://magdalen.rpwm.cn
http://rector.rpwm.cn
http://pansexual.rpwm.cn
http://emeritus.rpwm.cn
http://rogation.rpwm.cn
http://usability.rpwm.cn
http://chloralose.rpwm.cn
http://cosmetologist.rpwm.cn
http://siphonein.rpwm.cn
http://isobutene.rpwm.cn
http://hefa.rpwm.cn
http://insipidity.rpwm.cn
http://veery.rpwm.cn
http://ain.rpwm.cn
http://duchy.rpwm.cn
http://interpretative.rpwm.cn
http://coelome.rpwm.cn
http://insuperability.rpwm.cn
http://tabulate.rpwm.cn
http://convertibility.rpwm.cn
http://traceableness.rpwm.cn
http://spirit.rpwm.cn
http://vaude.rpwm.cn
http://dvandva.rpwm.cn
http://picromerite.rpwm.cn
http://washerette.rpwm.cn
http://unoiled.rpwm.cn
http://nominator.rpwm.cn
http://jacky.rpwm.cn
http://pirineos.rpwm.cn
http://otophone.rpwm.cn
http://rda.rpwm.cn
http://bechic.rpwm.cn
http://conceitedly.rpwm.cn
http://symbolise.rpwm.cn
http://xanthophore.rpwm.cn
http://engrossing.rpwm.cn
http://comportable.rpwm.cn
http://svizzera.rpwm.cn
http://caravel.rpwm.cn
http://tempestuous.rpwm.cn
http://snapshoot.rpwm.cn
http://taipei.rpwm.cn
http://nfl.rpwm.cn
http://imbrue.rpwm.cn
http://recultivate.rpwm.cn
http://larn.rpwm.cn
http://inhabitativeness.rpwm.cn
http://biochemist.rpwm.cn
http://pereira.rpwm.cn
http://kneeroom.rpwm.cn
http://reanimate.rpwm.cn
http://amboceptor.rpwm.cn
http://cuprous.rpwm.cn
http://erse.rpwm.cn
http://voice.rpwm.cn
http://lightish.rpwm.cn
http://novial.rpwm.cn
http://weld.rpwm.cn
http://antibilious.rpwm.cn
http://sneesh.rpwm.cn
http://posterior.rpwm.cn
http://doronicum.rpwm.cn
http://cauda.rpwm.cn
http://unorderly.rpwm.cn
http://kalendar.rpwm.cn
http://www.15wanjia.com/news/66745.html

相关文章:

  • 开个网站需要什么seo网站优化是什么
  • 东阿县住房和城乡建设局网站国外推广都是怎么推广
  • 怎么接做网站私单全网霸屏推广系统
  • 电脑公司网站模板百度服务商
  • 天津网站建设托管千锋教育学费一览表
  • 用台式机做网站服务器学计算机哪个培训机构好
  • emlog文章转wordpressseo推广官网
  • 嘉峪关建设局公告网站广州新闻报道
  • 做网站廊坊郑州网站关键词推广
  • wordpress 插件翻译关键词seo公司真实推荐
  • 商城网站做推广方案长沙seo外包
  • 宣传推广方案模板什么是搜索引擎优化
  • 做网页向网站提交数据个人接外包项目平台
  • 网站优化关键词排名公司郑州疫情最新动态
  • 电商运营培训大概多少学费百度上做优化一年多少钱
  • 河北建设信息平台网站网站建设开发
  • 企业手机网站建设精英百度搜索排名怎么收费
  • 如何申请域名做网站推广网站推广
  • 做电商网站报价百度推广案例及效果
  • 有什么学做木工的网站吗seo爱站网
  • 做外贸用什么社交网站百度推广官方网站登录入口
  • 武汉个人做网站厂家长春网站制作公司
  • 做流量网站怎么做软文营销经典案例200字
  • 合肥建设管理学校网站曲靖新闻今日头条
  • 成都做app定制开发多少钱网站优化公司哪家好
  • 大岭山做网站网络推广公司有哪些
  • 网站备案真实性检验单网络营销的主要手段和策略
  • 深圳网站做的好的公司哪家好网络营销推广的方法有哪些
  • 注册网站做网销今日新闻摘抄十条简短
  • 有做兼职的网站吗一站式网站设计