s

#include <bits/stdc++.h>
using namespace std;
#define sc(x) scanf("%lld", &(x))
#define pr(x) printf("%lld\n", x)
#define fi first
#define se second
#define eb emplace_back
#define endl '\n'
#define int ll
#define rep(i, j, k) for (ll(i) = (j); (i) <= (k); (++i))
#define rrep(i, j, k) for (ll i = (ll)(j); i >= (ll)(k); i--)
#define mem(x, y) memset(x, y, sizeof(x))
typedef long double ld;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ld pi = acos(-1);
const int mod = 1e9 + 7;
const ll INF = LLONG_MAX;
const int N = 1e5 + 7;
signed main() {
    int a, b, c, n;
    cin >> a >> b >> c >> n;
    string s1, s2, s3;
    if (max(a, max(b, c)) + min(a, min(b, c)) > n)
        return cout << "NO" << endl, 0;
    rep(i, 1, a) s1 += 'a', s2 += 'a';
    rep(i, 1, n - a) s1 += 'a', s2 += 'b';
    rep(i, 1, n) s3 += 'c';
    if (a <= b and b <= c) {
        if (c - a + b >= n)
            return cout << "NO" << endl, 0;
        rep(i, 1, b) s3[i - 1] = s2[i - 1];
        rrep(i, n - 1, n - (c - a)) s3[i] = s1[i];
    } else if (b <= a and a <= c) {
        rep(i, 1, b) s3[i - 1] = s1[i - 1];
        rrep(i, n - 1, n - (c - b)) s3[i] = s1[i];
    } else if (a <= c and c <= b) {
        if (c - a + b >= n)
            return cout << "NO" << endl, 0;
        rep(i, 1, b) s3[i - 1] = s2[i - 1];
        rrep(i, n - 1, n - (c - a)) s3[i] = s1[i];
    } else if (b <= c and c <= a) {
        rep(i, 1, b) s3[i - 1] = s1[i - 1];
        rrep(i, n - 1, n - (c - b)) s3[i] = s1[i];
    } else if (c <= b and b <= a) {

        rep(i, 1, c) s3[i - 1] = s1[i - 1];
        rrep(i, n - 1, n - (b - c)) s3[i] = s2[i];
    } else if (c <= a and a <= b) {
        rep(i, 1, c) s3[i - 1] = s1[i - 1];
        rrep(i, n - 1, n - (b - c)) s3[i] = s2[i];
    }
    cout << s1 << '\n' << s2 << '\n' << s3 << endl;
    return 0;
}
/*
2 1 3 4
*/

图片说明

package test16;

/*
*
* 编写一个Book类,有price成员变量,该类实现Comparable接口,
* 在接口中的compareTo()方法中规定Book类两个实例的大小关系为二者的price成员的大小关系。
* 编写一个主类Test16,在main()方法中将Book类的若干个对象存放到一个链表中,
* 然后再用Book类创建一个新的对象,
* 并检查这个对象和链表中哪些对象相等。
*
*
* */

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;

class Book implements Comparator {
    private String name;
    private int price;

    public Book(String name, int price) {
        super();
        this.name = name;
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public Book() {
        super();
    }

    @Override
    public int compare(Object o1, Object o2) {
        return ((Book) o1).price - ((Book) o2).price;
    }

    public int compareTo(Object b) {
        if (((Book) b).price - this.price == 0)
            return 0;
        if (((Book) b).price - this.price >= 0)
            return 1;
        return -1;
    }
}

public class Test16 {
    public static void main(String[] args) {
        ArrayList<Book> list = new ArrayList<>();
        list.add(new Book("Java基础教程", 25));
        list.add(new Book("C++基础教程", 25));
        list.add(new Book("HTML基础教程", 29));
        list.add(new Book("数据库技术 ", 29));
        list.add(new Book("Python基础教程", 28));
        list.add(new Book("计算机网络", 28));
        Iterator<Book> it = list.iterator();

        Book book = new Book("计算机及组成原理", 28);

        System.out.println("新书:" + book.getName() + " 与下列图书:");
        while (it.hasNext()) {
            Book b = it.next();
            if (book.compareTo(b) == 0)
                System.out.println(b.getName());
        }
        System.out.println("价格相同,具体价格为:" + book.getPrice() + "元");
    }
}
全部评论

相关推荐

如题,字节跳动怎么才能看到自己的面评,找hr说看不到
SoulStar:自己应该看不到,这个是字节比较保密的信息,之前有mentor加我,说他能看到,但是不能给我说,给我说了他可能就要被辞退了
点赞 评论 收藏
分享
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务