海选女主角

作者首次尝试使用C++解决编程问题,记录了从头到尾的编程过程,分享了遇到的困难与解决方法,包括使用各种C++标准库如iostream、cmath等进行数组操作和寻找最大值的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

第一次c++写题,哈哈哈
漏洞百出
在这里插入图片描述
在这里插入图片描述

#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=1000;
long long a[maxn][maxn];
int main()
{
    int n,m;
    while(cin>>m>>n){
        memset(a,0,sizeof(a));
        for(int i=0;i<m;i++)
            for(int j=0;j<n;j++)
                cin>>a[i][j];
        long long maxx=a[0][0];
        int h=0,l=0;
        for(int i=0;i<m;i++)
            for(int j=0;j<n;j++){
                if(abs(a[i][j])>abs(maxx)){
                    maxx=a[i][j];
                    h=i+1,l=j+1;
                }
            }
        cout<<h<<" "<<l<<" "<<maxx<<endl;
    }
    return 0;
}
才艺大赛海选Java是一个模拟海选过程的Java程序。该程序定义了一个接口Perform才艺大赛海选Java是一个模拟海选过程的Java程序。该程序定义了一个接口Performable,包含方法play,然后定义了Monkey类和Lion类实现该接口,重写方法play,分别输出“Monkey翻跟头”和“Lion唱摇滚”。接着定义了Coach类,该类有方法check,来海选每一个选手,让选手调用play方法展示才艺。最后在Main类中创建Coach类对象,调用check方法,分别海选Monkey对象和Lion对象。 具体实现过程如下: 1. 定义接口Performable,包含方法play。 2. 定义Monkey类实现该接口,重写方法play,输出“Monkey翻跟头”。 3. 定义Lion类实现该接口,重写方法play,输出“Lion唱摇滚”。 4. 定义Coach类,该类有方法check,来海选每一个选手,让选手调用play方法展示才艺。 5. 在Main类中创建Coach类对象,调用check方法,分别海选Monkey对象和Lion对象。 代码实现如下: ``` interface Performable { public void play(); } class Monkey implements Performable { public void play() { System.out.println("Monkey翻跟头"); } } class Lion implements Performable { public void play() { System.out.println("Lion唱摇滚"); } } class Coach { public void check() { Monkey monkey = new Monkey(); Lion lion = new Lion(); monkey.play(); lion.play(); } } public class Main { public static void main(String[] args) { Coach coach = new Coach(); coach.check(); } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值