七下信息复习

· · 学习·文化课

人工智能

人工智能(Artificial Intelligence)
是一个以计算机科学(Computer Science)为基础的一门新技术科学
生产一种新的能以人类智能相似的方式做出反应的智能机器

扫雷

随机函数

srand(time(0)) //随机种子

rand() //调用

扫雷代码

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int h,w,mine;
int vis[110][110];
int a[110][110];
int gox[]={1,1,-1,-1,0,0,1,-1};
int goy[]={1,-1,1,-1,1,-1,0,0};
int flot=0; //0表示正在进行,1表示胜利,-1表示失败
void mined(int x,int y)
{
    a[x][y]=114514;
    for(int i=0;i<8;i++)
    {
        int xx=x+gox[i];
        int yy=y+goy[i];
        if(xx<1||yy<1||xx>h||yy>w||a[xx][yy]==114514) continue;
        a[xx][yy]++;
    }
    return ;
}
void build()
{
    srand(time(0));
    while(mine)
    {
        int x=rand()%h+1;
        int y=rand()%w+1;
        if(a[x][y]!=114514)
        {
            mine--;
            mined(x,y);
        }
    }
    return ;
}
void write()
{
    system("CLS");
    cout<<"   ";
    for(int i=1;i<=w;i++) cout<<" "<<i;
    cout<<"\n\n";
    for(int i=1;i<=h;i++)
    {
        cout<<i<<"   ";
        for(int j=1;j<=w;j++)
        {
            if(vis[i][j]) cout<<a[i][j]<<" ";
            else cout<<"? ";
        }
        cout<<"\n";
    }
    return ;
}
void click(int x,int y)
{
    if(vis[x][y]) return ;
    vis[x][y]=1;
    if(a[x][y]==0)
    {
        for(int i=0;i<8;i++)
        {
            int xx=x+gox[i];
            int yy=y+goy[i];
            if(xx<1||yy<1||xx>h||yy>w||a[xx][yy]==114514) continue;
            click(xx,yy);
        }
    }
    if(a[x][y]==114514)
    {
        flot=-1;
        for(int i=1;i<=h;i++)
            for(int j=1;j<=w;j++) vis[i][j]=1;
        return ;
    }
}
bool check()
{
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            if((a[i][j]!=114514&&vis[i][j]==0)||(a[i][j]==114514&&vis[i][j]==1)) return 0;
    return 1;
}
int main()
{
    cout<<"h = 9\nw = 9\n";
    cout<<"The number of mines is 10\n";
    h=9;
    w=9;
    mine=10;
    build();
    int x,y;
    while(flot==0)
    {
        write();
        cout<<"Please enter the X coordinate and Y\n";
        cin>>x>>y;
        if(x>=1&&x<=h&&y>=1&&y<=w) click(x,y);
        if(check()) flot=1;
    }
    write();
    if(flot==1) cout<<"Congratulations on completing the challenge\n";
    else cout<<"You're a rookie\n";
    return 0;
}

光线追踪

定义

光线跟踪,是一个在二维(2D)屏幕上呈现三维(3D)图像的方法。 广泛用于计算机游戏和动画

方法

图1 光线追踪技术原理图。光线从人眼方向射出,透射在绿色球体表面,
通过折射,一部分光线又被投射在红色三角形上,并同时产生自然阴影。

C++Bepp

基础知识

在C++中,Beep函数来发出声音。Beep函数通过控制主板扬声器的发声频率和时长来产生声音。

#include<windows.h>

Beep(523,400) //频率为523Hz,发生400ms

一拍是400毫秒
do是523Hz

C++歌曲

天空之城

图片

手机壁纸 9:16
微信头像 1:1
海报 3:4

图灵完备

NAND

(1,1)->0
(1,0)->1
(0,1)->1
(0,0)->1

NOT

NAND(A,A)

AND,OR,NOR

AND : NAND输出取反
OR : NAND输入取反
NOR : NAND输入输出都取反

XOR

(-A&B)|(A&-B)