AI 摘要

本文代码展示了两个不同主题的 C++ 代码片段,且均未包含标题“code highlight test”中提到的代码高亮效果。 第一部分代码展示的是一个包含一些库和一些函数的 C++ 程序,其中包括 `tree`, `vector`, `set`, `sqrt`, `long long int`, 等等内容的使用。程序通过调用 `cal()` 函数计算了数学算式 $x^2 + 2 sqrt{x}$ 的值。程序还拥有名为 `cheak()` 的函数,该函数接受一个参数 $n$,并据此根据一些逻辑操作返回布尔值。程序还使用了 `cin` 和 `cout` 加速输入输出的操作。 第二部分代码展示了 “doubleLinklist”,即双向链表的数据结构,其中定义了用于 `create()` 创建结点,`insert()` 用于向链表中添加元素的操作,以及 `delete_node()` 和 `Print()` 两个函数,分别用于从双向链表中删除特定元素和输出当前链表中的所有元素。 需要注意的是,由于原文当中代码格式不美观,此处转化为网页展示也会影响美观度。
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define pb push_back


using namespace __gnu_pbds;
using namespace std;

typedef tree<long long int, null_type, less_equal<long long int>, rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_multiset;
//ordered_multiset s3;
//ordered_multiset :: iterator it;
const ll mod=1e9+7;

const ll N=1e1;
bool sive[N];
vector<ll>prime;
vector<ll>v;
vector<ll>p;
set<ll>s;
set<ll>:: iterator it;
ll k,num,m;

long long int gcd(long long int a,long long int b)
{
    long long int c;
    while(a%b!=0)
    {
        c=b;
        b=a%b;
        a=c;
    }
    return b;
}
double cal(double x)
{
    double y=sqrt(x);
    return(x*x+2*y);
}
bool cheak(ll n)
{
    ll b,c,a;
    if(n>=k)
    {
        a=(((n*(n+1))/2)-((n-k)*((n-k)+1)/2));
    }
    else{
        a=((n*(n+1))/2)+k-n;
    }
    ll n1=n-1;
    c=num-k;
    if(c<=n1)
    {
        b=(((n1*(n1+1))/2)-(((n1-c)*((n1-c)+1))/2));
    }
    else{

        b=((n1*(n1+1))/2)+c-n1;

    }


    if(a+b<=m)
        return true;
    else
        return false;

}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll i,j;
    for(i=0; i<N; i++)
    {
        sive[i]=true;
    }
    sive[0]=false;
    sive[1]=false;
    for(i=2; i*i<=N; i++)
#include <bits/stdc++.h>
using namespace std;

struct doubleLinklist{
    int val;
    doubleLinklist* forward;
    doubleLinklist* backward;

};

struct doubleLinklist* create(int val){
    struct doubleLinklist* new_element = new doubleLinklist;
    new_element->val = val;
    new_element ->forward = NULL;
    new_element->backward = NULL;
    return new_element;
}

void insert(doubleLinklist* &first_element,int val){
    struct doubleLinklist* new_element = create(val);
    first_element->forward = new_element;
    new_element->backward = first_element;
    first_element = first_element->forward;
}

void delete_node(doubleLinklist*& head,doubleLinklist* &tail,int val){
    doubleLinklist* head1 = head;
    doubleLinklist* tail1 = tail;
    if(head == tail){
        if(head->val == val){
           doubleLinklist* temp = head;
           head = NULL;
           tail= NULL;
           delete temp;
        }
    }
    else if(head->val == val){
        doubleLinklist* temp = head;
        head= head->forward;
        head->backward = NULL;
        delete temp;
    }
    else if(tail->val == val){
        doubleLinklist* temp = tail;
        tail= tail->backward;
        tail->forward= NULL;
        delete temp;
    }
    else {
        while(head1 != tail1){
            if(head1->val == val){
                doubleLinklist* temp = head1;
                doubleLinklist* prev = head1->backward;
                doubleLinklist* next = head1->forward;
                delete temp;
                prev->forward = next;
                next->backward = prev;
                break;
            }
            head1= head1->forward;
        }
    }
}
void Print(doubleLinklist* head){
     while(head){
        cout<< head->val <<" ";
        head= head->forward;
    }
    cout<<"\n";
}

int main(){
    doubleLinklist * head = create(0);
    doubleLinklist* tail = head;
    //insert(tail,1);
    delete_node(head,tail,0);
    Print(head);
}