3351:练60.5 素数筛选
3352:练60.6 胡萝卜与骨头
/*
15根胡萝卜 15根骨头
1-9
*/
#include<iostream>
using namespace std;
int main()
{
int i,a[31],num=0,k=0;
for(i=1;i<=30;i++)
a[i]=0;
while(num<15)
{
for(i=1;i<=30;i++)
{
if(a[i]==1) continue;
k++;
if(k==9)
{
a[i]=1;
k=0;
num++;
if(num==15) break;
}
}
}
//cout<<"骨头所在的位置:";
for(i=1;i<=30;i++)
if(a[i]==0) cout<<i<<" ";
return 0;
}
/*
作业:
P2550 [AHOI2001]彩票摇奖
https://www.luogu.com.cn/problem/P2550
P2615 [NOIP2015 提高组] 神奇的幻方
https://www.luogu.com.cn/problem/P2615
P5730 【深基5.例10】显示屏
https://www.luogu.com.cn/problem/P5730
*/
3353:【例61.1】 机器翻译
/*
1.12编程基础之函数与过程抽象 07 机器翻译 STL AC
https://www.luogu.com.cn/problem/P1540
http://noi.openjudge.cn/ch0112/07/
*/
#include <vector>
#include <iostream>
#include <algorithm>
int main() {
int m, n, t, ans = 0;
//第一行为两个正整数M和N,代表内存容量和文章的长度。
std::cin >> m >> n;
std::vector<int> v; // 用来表示内存
//第二行为N个非负整数,按照文章的顺序,每
//个数(大小不超过1000)代表一个英文单词。
//文章中两个单词是同一个单词,当且仅当它们对应的非负整数相同。
while (std::cin >> t) {
if (std::find(v.begin(), v.end(), t) == v.end()) { // 如果不在内存中
v.push_back(t); // 加入内存
++ans;
}
if (v.size() > m) // 内存满了
v.erase(v.begin()); // 把第一个单词删掉
}
std::cout << ans << std::endl;
}
3354:【例61.2】 最近的一对
3355:【例61.3】 图书管理员
1028.练习3:蛇形矩阵2(课程ZA)
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,t=0;
cin>>n;
for(int i=1;i<=n;i++) {
if(i%2!=0)
for(int j=1;j<=i;j++){
cout<<t+j<<" ";
}
else
for(int j=i;j>=1;j--)
cout<<t+j<<" ";
cout<<endl;
t+=i;
}
return 0;
}
1029.练习4:蛇形矩阵3(课程ZA)
#include <bits/stdc++.h>
using namespace std;
int a[105][105];
int main()
{
int n,x,y,tot;
cin>>n;
memset(a,0,sizeof(a));
tot=a[x=0][y=n-1]=1;
while(tot<n*n)
{
while(x+1<n&&!a[x+1][y]) a[++x][y]=++tot;
while(y-1>=0&&!a[x][y-1]) a[x][--y]=++tot;
while(x-1>=0&&!a[x-1][y]) a[--x][y]=++tot;
while(x+1<n&&!a[x][y+1]) a[x][++y]=++tot;
}
for(int i=n-1;i>=0;i--)
{
for(int j=0;j<n;++j) cout<<a[j][i]<<" ";
cout<<endl;
}
return 0;
}
758.输入变量
760.三个猴子
762.四丛草
第1集 | 想学好线性代数,一定要掌握这个概念
第2集 | 解决数学问题就是找基?
第3集 | 究竟应该怎么看待解方程组?
第4集 | 所以,到底什么是行列式?
图灵与欧拉