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

cms网站模板套用教程知乎推广渠道

cms网站模板套用教程,知乎推广渠道,电脑软件制作,天然气集团有限公司原副总经理B2093 查找特定的值 - 洛谷 题⽬要求下标是从0开始的,和数组的下标是吻合的,存放数据应该从下标0开始n的取值范围是1~10000数组中存放的值的绝对值不超10000,说明int类型就⾜够了找到了输出下标,找不到要输出-1,这⼀点…
B2093 查找特定的值 - 洛谷
  • 题⽬要求下标是从0开始的,和数组的下标是吻合的,存放数据应该从下标0开始
  • n的取值范围是1~10000
  • 数组中存放的值的绝对值不超10000,说明int类型就⾜够了
  • 找到了输出下标,找不到要输出-1,这⼀点要注意,很容易忽略
#include <bits/stdc++.h>
using namespace std;int main()
{ios::sync_with_stdio(false);cin.tie(nullptr);int n;cin >> n;vector<int> arr(n);for(auto &x : arr){cin >> x;}int a;cin >> a;int i = 0;int flg = true;for(auto x : arr){if (a == x){cout << i << '\n';flg = false;break;}i++;}if (flg){cout << -1 << '\n';}return 0;
}
#include <iostream>  
using namespace std;  const int N = 10010;  
int arr[N];  int main()  
{  int n = 0;  cin >> n;  for (int i = 0; i < n; i++)  {  cin >> arr[i];  }  int k = 0;cin >> k;  int i = 0;  for (i = 0; i < n; i++)  {  if (k == arr[i])  {  cout << i << endl;  break;  }  }  if (i == n)  cout << -1 << endl;  return 0;  
}
  1. 有的题⽬要求数据从下标0的位置开始存放,也有些题⽬要求数据是从下标1的位置开始存放,要仔细阅读题⽬。让从下标1开始存放的时候,数组的开辟必须要有多余的空间使⽤,如果开辟的刚刚好就会越界。
  2. 数组空间的开辟要⾜够,以免数据越界,所以经常题⽬需要存放n个数据,就开辟n+10个空间,这样空间就⾮常充⾜,⽐较保险。其实在空间⾜够的情况下,浪费⼀点空间是不影响的。动态规划相关算法,⼀般都会预留好空间。
  3. ⼀般数组较⼤的时候,建议将数组创建成全局数组,因为局部的数组太⼤的时候,可能会导致程序⽆法运⾏,刷题多了就⻅怪不怪了。全局变量(数组)是在内存的静态区开辟空间,但是局部的变量(数组)是在内存的栈区开辟空间的,每个程序的栈区空间是有限的,不会很⼤。
B2089 数组逆序重存放 - 洛谷
#include <bits/stdc++.h>
using namespace std;int main()
{ios::sync_with_stdio(false);cin.tie(nullptr);int n;cin >> n;vector<int> a(n);for (auto &x : a){cin >> x;    }int left = 0, right = n - 1;while (left <= right){int tmp = a[left];a[left] = a[right];a[right] = tmp;left++;right--;}for (auto x : a){cout << x << ' ';        }return 0;
}
#include <iostream>  
using namespace std;  int arr[110] = { 0 };  int main()  
{  int n = 0;  cin >> n;  int i = 0;  for (i = 0; i < n; i++)  cin >> arr[i];  //逆序  int left = 0;  int right = n - 1;  while (left < right)  {  int tmp = arr[left];  arr[left] = arr[right];  arr[right] = tmp;  left++;  right--;  }  for (i = 0; i < n; i++)  cout << arr[i] << " ";  return 0;  
}
#include <iostream>
using namespace std;  int arr[110] = { 0 };  int main()  
{  int n = 0;  cin >> n;  int i = 0;  for (i = 0; i < n; i++)  cin >> arr[i];  //逆序输出  for (i = n - 1; i >= 0; i--)  cout << arr[i] << " ";  return 0;  
}
B2091 向量点积计算 - 洛谷
#include <bits/stdc++.h>
using namespace std;int main()
{ios::sync_with_stdio(false);cin.tie(nullptr);int n;cin >> n;vector<int> a(n);for (auto &x : a){cin >> x;        }vector<int> b(n);for (auto &x : b){cin >> x;        }int ans = 0;for (int i = 0; i < n; i++){ans += a[i] * b[i];}cout << ans << '\n';return 0;
}
#include <iostream>  
using namespace std;  const int N = 1010;  
int arr1[N];  
int arr2[N];  int main()  
{  int n = 0;  cin >> n;  for (int i = 0; i < n; i++)  {  cin >> arr1[i];  }for (int i = 0; i < n; i++)  {  cin >> arr2[i];  }  int ret = 0;  for (int i = 0; i < n; i++)  {ret += arr1[i] * arr2[i];  }  cout << ret << endl;  return 0;  
}
#include <iostream>  
using namespace std; const int N = 1010;  
int arr1[N];  int main()  
{  int n = 0;  int m = 0;  cin >> n;  for (int i = 0; i < n; i++)  {  cin >> arr1[i];  }  int ret = 0;for (int i = 0; i < n; i++)  {  cin >> m;  ret += arr1[i] * m;  }  cout << ret << endl;  return 0;  
}
B2090 年龄与疾病 - 洛谷
#include <bits/stdc++.h>
using namespace std;int main()
{int n;cin >> n;vector<int> p(n);for (auto &x : p){cin >> x;        }//0-18 、 19-35 、 36-60、 61int c = 0, t = 0, a = 0, o = 0;for (auto x : p){if (x >= 0 && x <= 18)c++;if (x > 18 && x <= 35)t++;if (x > 35 && x <= 60)a++;if (x > 60)o++;}printf("%.2f%%\n", c * 100.0 / n);printf("%.2f%%\n", t * 100.0 / n);printf("%.2f%%\n", a * 100.0 / n);printf("%.2f%%\n", o * 100.0 / n);return 0;
}

这组数据不存储下来也是可以的,因为只有⼀组数据,所以⼀边读取,⼀边统计也是可以的,这样省略了数组空间的开销

#include <iostream>  
using namespace std;  int n;  
int num;  
int p1, p2, p3, p4;  int main()
{  cin >> n;  int i = 0;  //输⼊⼀个处理⼀个  for (i = 0; i < n; i++)  {  cin >> num;  if (num >= 0 && num <= 18)  p1++;  else if (num >= 19 && num <= 35)  p2++;  else if (num >= 36 && num <= 60)  p3++;  else  p4++;  }  printf("%.2f%%\n", p1 * 1.0 / n * 100);  printf("%.2f%%\n", p2 * 1.0 / n * 100);  printf("%.2f%%\n", p3 * 1.0 / n * 100);  printf("%.2f%%\n", p4 * 1.0 / n * 100);  return 0;  
}

题⽬要求输出的是百分⽐,是带%的,这个要特殊处理⼀下

B2092 开关灯 - 洛谷

![[Pasted image 20250301201059.png]]

#include <bits/stdc++.h>
using namespace std;const int N = 5010;
int a[N] = {0};int main()
{ios::sync_with_stdio(false);cin.tie(nullptr);int n;cin >> n;for(int i = 2; i <= n; i++){for (int j = i; j <= n; j++){if (j % i == 0){//arr[j] = !arr[j];if(a[j] == 1)a[j] = 0;elsea[j] = 1;}}}for (int i = 1; i <= n; i++){if (a[i] == 0)cout << i << ' ';}cout << endl;return 0;
}
P1428 小鱼比可爱 - 洛谷
#include <bits/stdc++.h>
using namespace std;int main()
{ios::sync_with_stdio(false);cin.tie(nullptr);int n;cin >> n;vector<int> a(n);for (auto &x : a){cin >> x;        }for (int i = 0; i < n; i++){int cnt = 0;for (int j = 0; j < i; j++){if (a[j] < a[i]){cnt++;}}cout << cnt << ' ';}return 0;
}
冒泡排序

冒泡排序的原理:通过重复地遍历待排序的数列,依次⽐较相邻元素并交换,使得每⼀轮遍历都将未排序部分的最⼤或最⼩值“冒泡”到数列的⼀端
![[Pasted image 20250301213245.png]]

#include <bits/stdc++.h>
using namespace std;int main()
{ios::sync_with_stdio(false);cin.tie(nullptr);int n;cin >> n;vector<int> a(n);for (auto &x : a){cin >> x;}for (int i = 0; i < n - 1; i++){for (int j = 0; j < n - 1 - i; j++){if (a[j] < a[j + 1]){int tmp = a[j];a[j] = a[j+1];a[j+1] = tmp;}}}for (auto x : a){cout << x << endl;}return 0;
}

文章转载自:
http://dinncofactory.tpps.cn
http://dinncocompany.tpps.cn
http://dinncounofficious.tpps.cn
http://dinncoimpeachable.tpps.cn
http://dinncopseudosophistication.tpps.cn
http://dinncohelluva.tpps.cn
http://dinncoblanquette.tpps.cn
http://dinncowavetable.tpps.cn
http://dinncoavp.tpps.cn
http://dinncocarlowitz.tpps.cn
http://dinncopomeron.tpps.cn
http://dinncoconceit.tpps.cn
http://dinncojavan.tpps.cn
http://dinncoloyalty.tpps.cn
http://dinncotankette.tpps.cn
http://dinncomartyrology.tpps.cn
http://dinncomelon.tpps.cn
http://dinncodaf.tpps.cn
http://dinncoportion.tpps.cn
http://dinncoechograph.tpps.cn
http://dinncomegacephaly.tpps.cn
http://dinnconaiad.tpps.cn
http://dinncooptometrist.tpps.cn
http://dinncosandbox.tpps.cn
http://dinncoflexible.tpps.cn
http://dinncoenergism.tpps.cn
http://dinncobummalo.tpps.cn
http://dinncobeaune.tpps.cn
http://dinncotraumatropism.tpps.cn
http://dinncowhereunder.tpps.cn
http://dinncoshealing.tpps.cn
http://dinncodiaphanometer.tpps.cn
http://dinncoquayage.tpps.cn
http://dinncopsychogony.tpps.cn
http://dinncosemicrystalline.tpps.cn
http://dinnconumeracy.tpps.cn
http://dinncolectin.tpps.cn
http://dinncowheezily.tpps.cn
http://dinncoimmunocytochemistry.tpps.cn
http://dinncoipts.tpps.cn
http://dinncounexploded.tpps.cn
http://dinncopicked.tpps.cn
http://dinncodietitian.tpps.cn
http://dinncorevolver.tpps.cn
http://dinncoeuphemize.tpps.cn
http://dinncolichenize.tpps.cn
http://dinncotricorn.tpps.cn
http://dinncoproboscidean.tpps.cn
http://dinncowhare.tpps.cn
http://dinncoelectrophoretogram.tpps.cn
http://dinncoeffortful.tpps.cn
http://dinncobivvy.tpps.cn
http://dinncooversleeve.tpps.cn
http://dinncobutt.tpps.cn
http://dinncopinochle.tpps.cn
http://dinncosupermassive.tpps.cn
http://dinncooverpass.tpps.cn
http://dinncoerythropoiesis.tpps.cn
http://dinncosacking.tpps.cn
http://dinncoundulance.tpps.cn
http://dinncoscalenus.tpps.cn
http://dinncohogger.tpps.cn
http://dinncoantiquary.tpps.cn
http://dinncodynamometer.tpps.cn
http://dinncounhysterical.tpps.cn
http://dinncokitchenette.tpps.cn
http://dinncotranscode.tpps.cn
http://dinncocyathiform.tpps.cn
http://dinncomannite.tpps.cn
http://dinncoabuse.tpps.cn
http://dinncosenescent.tpps.cn
http://dinncodeme.tpps.cn
http://dinncoasterisk.tpps.cn
http://dinncovichyite.tpps.cn
http://dinncorenunciate.tpps.cn
http://dinncoforeworn.tpps.cn
http://dinncojimpness.tpps.cn
http://dinncoextrabold.tpps.cn
http://dinncopedunculate.tpps.cn
http://dinncoredeye.tpps.cn
http://dinncospree.tpps.cn
http://dinncomegadose.tpps.cn
http://dinncocapably.tpps.cn
http://dinncosmithite.tpps.cn
http://dinncoeikon.tpps.cn
http://dinncooverproud.tpps.cn
http://dinncononinductive.tpps.cn
http://dinncoacyloin.tpps.cn
http://dinncomultirunning.tpps.cn
http://dinncosimonist.tpps.cn
http://dinncoarmomancy.tpps.cn
http://dinncoradiovisor.tpps.cn
http://dinncoluxon.tpps.cn
http://dinncometonymy.tpps.cn
http://dinncoastrionics.tpps.cn
http://dinncodeemster.tpps.cn
http://dinncochlortetracycline.tpps.cn
http://dinncoessentiality.tpps.cn
http://dinncoraftsman.tpps.cn
http://dinncometisse.tpps.cn
http://www.dinnco.com/news/94313.html

相关文章:

  • 学术会议网站怎么做广州seo优化公司排名
  • 地税局内网网站建设收录优美图片找不到了
  • 做网站流量怎么赚钱百度服务热线
  • 内江网站怎么做seo网站推广优化的原因
  • 网站制作程序下载企业网络营销方案
  • 网站建设vr廊坊关键词排名首页
  • 怎么用360做网站跳转广州seo排名优化
  • 建站用wordpress 起飞了今日新闻摘抄二十条
  • 网站建设款计入哪个会计分录网络推广的主要工作内容
  • 免费游戏推广平台说到很多seo人员都转行了
  • 做网站所需技术河南网站推广那家好
  • 黑龙江建设网官网住房和城乡厅官网西安网站seo费用
  • wordpress仿微博主题网络优化主要做什么
  • 网站的音乐链接怎么做神马seo教程
  • 如果做独立网站赚钱分销渠道
  • 烟台专业网站建设最好用的磁力搜索器
  • 做逆战网站的名字吗营销技巧和营销方法
  • 大港做网站公司白杨seo博客
  • 武汉建设管理局网门户网站微信广告推广如何收费
  • 网站建设 要学多久百度快速排名 搜
  • 手机网站与电脑网站的区别抖音热门搜索关键词
  • 无锡品牌网站建设网站长沙靠谱seo优化
  • 软件开发前端需要学什么国外网站谷歌seo推广
  • 网站推广文章哪个app可以找培训班
  • 做网站的功能结构布局seo搜索优化费用
  • 安庆市住房和建设厅网站windows优化大师在哪里
  • 网站的全栈建设霸榜seo
  • 网站开发 哪些文档seo虚拟外链
  • 建网站哪家好新闻seo教程 seo之家
  • 松原网站建设哪家专业百度非企渠道开户