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

学校门户网站建设方案优化大师有必要安装吗

学校门户网站建设方案,优化大师有必要安装吗,手游排行榜前十名网络游戏,彩票网站开发亿云1.第一个题,大概题目意思是求n句话中最长的单词和最短的单词 这个题目做的有点磕巴,好几年没有写过c/c了,连string的复制都不会写了,哈哈哈,太笨了 后面一点点捡起来,还是写出来了,本身没啥&…

1.第一个题,大概题目意思是求n句话中最长的单词和最短的单词
这个题目做的有点磕巴,好几年没有写过c/c++了,连string的复制都不会写了,哈哈哈,太笨了
后面一点点捡起来,还是写出来了,本身没啥;
第一:整行读入,要自己分单词
第二: 就是复制的时候是浅层copy还是深层copy,这里也忘记那个是深那个是浅了,反正就是一个直接复制地址,一个是复制内容。
粗暴的代码:


#include<vector>
#include<cmath>
#include<cstring>
#include <iostream>
#include<algorithm>
using namespace std;
vector<string> str;
vector<int> str_leng;
int main(){int num;cin >> num;string line;int min_num=10000;int max_num=0;char max_str[1000]="",min_str[1000]="";getline(cin,line);while(num){getline(cin,line);if (1){
//             cout <<num<< line << endl;int len=0;char tmp[1000]="";for (int i=0;i<line.length();i++){if (line[i]!=' '){tmp[len]=line[i];len++;}if(line[i]==' ' | i==line.length()-1){tmp [len]='\0';
//                     cout<<tmp<<" len: "<<len<<endl;if (len>max_num){
//                         cout<<tmp<<endl;max_num=len;strcpy(max_str,tmp);}if(len<min_num){
//                          cout<<"min: "<<tmp<<endl;min_num = len;strcpy(min_str,tmp);}len=0;strcpy(tmp,"");}}}num--;}cout<<max_str<<endl;cout<<min_str<<endl;return 0;
}

2、就是对n个学生进行按成绩从高到低进行排序,成绩重复的按名字字典序从小到大排序
这里就是自己设置一个学生结构体,然后自定义个结构体排序就好了
还可以的代码:

沉默:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;struct student{char  name[20];int score;
};
bool com(const student x,const student y)
{if(x.score==y.score)return x.name<y.name;return x.score>y.score;
}
int main(){int n;cin >>n;student std[30];for(int i=0;i<n;i++){cin >> std[i].name >> std[i].score;}sort(std,std+n,com);for(int i=0;i<n;i++){cout<<std[i].name<<" "<<std[i].score<<endl;}return 0;
}

3题
请添加图片描述
代码:
数学计算题:

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;int main(){int n=1;int res=0;int tmp =0;for (int i=0;i<1;i++){tmp = (n+1)*2;n = tmp;}cout<< n<<endl;return 0;
}

请添加图片描述
用队列来表示能生存的数字,被队列抛弃的就是死掉的数字,最后只剩一个数的时候,就是最终答案。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
queue<int> q1;
int main(){int n;cin>>n;int id=1;int num=1;q1.push(id);bool flag=false;while(!q1.empty()){if(flag && q1.size()==1){cout<<q1.front()<<endl;return 0;}num++;if (id<n && !flag){id++;}else{flag=true;id=q1.front();q1.pop();}if(num==3){num=0;}else{q1.push(id);}}return 0;
}
http://www.hrbkazy.com/news/41167.html

相关文章:

  • 网站制作公司 重庆绍兴seo网站优化
  • 合肥市庐阳区住房和城乡建设局网站广告开户
  • 怎样更换网站cms百度指数有三个功能模块
  • wap网站html模板淘宝推广怎么推
  • 北京顺义建设委员会网站首页发稿网
  • 百度云建站网站建设产品推广文章
  • 东莞樟木头哪里有做网站的搜索引擎优化好做吗
  • 网站的图片怎么做显示和隐藏网站推广入口
  • wordpress 主题 更改郑州网站优化推广
  • 网站建设优化服务如何优化seo搜索
  • 500强企业排名一览表搜索引擎优化方法有哪几种
  • 松江做移动网站下载百度app免费下载安装
  • 微信如何做微商城网站建设广州今日刚刚发生的新闻
  • 做电脑系统哪个网站百度竞价培训班
  • centos怎么安装wordpressseo优化范畴
  • 柏乡企业做网站站长统计app进入网址新版小猪
  • 新会网站建设痘痘如何去除效果好
  • 长沙企业网站建设收费便民信息微信平台推广
  • 搭建wordpress深圳百度快照优化
  • wordpress 安装 权限项目优化seo
  • 鹰潭市城乡建设局老网站百度移动端关键词优化
  • 本地环境搭建网站国际新闻消息
  • 开网上授课的网站应该怎么做2022年7到8月份的十大新闻
  • 猪八戒设计平台官网seo网络营销推广公司深圳
  • 怎么制作网站横幅百度搜索引擎的功能
  • 网站开头flash怎么做沈阳沈河seo网站排名优化
  • 如何做网站的下载的二维码经典软文推广案例
  • 怎样做免费网站卖东西网站注册域名
  • 住房和城乡建设委网站夫唯seo
  • 深圳的网站建设公司价格企业网站建设平台