第二周总结

本次的周赛我感觉难度有些大,就写出来了一道,而且有的题看着题解也不是很明白,不过我这周也做了百度发的那个马蹄集,那些题稍微简单一点,本次博客就对那些题做一下总结.

该题主要是对横排和,竖排和以及对角线和进行对比,如果所有之和都相等,那么则符合条件.我感觉我做的有些bug,但是可以AC.我利用的是第一排的和,最后一列的和以及正反对角线的和来判断.

#include<iostream>
using namespace std;
int main(){
    int a[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
    int heng=0,shu=0,zheng=0,fan=0;
    for(int i=0;i<3;i++){
        heng+=a[0][i];
        shu+=a[i][0];
        zheng+=a[i][i];
        fan+=a[i][2-i];
    }
    if(heng==shu && shu==zheng && zheng==fan){
        cout<<"1"<<endl;
        
    }
    else cout<<"0"<<endl;
    return 0; 
}
s2+=a[i][j];                      //s2是第三行的和,放在这里是想加快程序的运行速度
        }
    }
    s1=a[0][0]+a[1][0]+a[2][0];                   //第一列和
    s3=a[0][2]+a[1][2]+a[2][2];                   //第三列和
    s4=a[0][0]+a[1][1]+a[2][2];                   //正对角线和

剩下再总结几道最近写的马蹄集的题目

#include<bits/stdc++.h> 

using namespace std;

int main( )
{
    int w[10];
    w[1]=1;
    for(int i=1;i<=10;++i){
        w[i]=i*i*i*i;
    }
    int n,sum=0,b;
    cin>>n;
    if(n<1000 || n>9999){
        cout<<"NO"<<endl;
        return 0 ;
    }
    b=n;
    while(b){
        sum=sum+w[b%10];
        b=b/10;    }
        if(sum==n){
            cout<<"YES"<<endl;
        }
        else {
            cout<<"NO"<<endl;
        }
    return 0;
}
#include<bits/stdc++.h> 

using namespace std;

int main( )
{
    int AX,AY,AZ,BX,BY,BZ,CX,CY,CZ;
    
    int s,p;
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf %lf",&AX,&AY,&AZ,&BX,&BY,&BZ,&CX,&CY,&CZ);
    double side[3];//存储三条边的长度;
 
    side[0] = sqrt(pow(AX - BX,2)+pow(AY - BY,2) + pow(AZ - BZ,2)); 
    side[1] = sqrt(pow(AX - CX,2)+pow(AY - CY,2) + pow(AZ - CZ,2));
    side[2] = sqrt(pow(CX - BX,2)+pow(CY - BY,2) + pow(CZ - BZ,2)); 


  p = (side[0]+side[1]+side[2])/2; //半周长;
    s= sqrt(p*(p-side[0])*(p-side[1])*(p-side[2])); 

    printf("%.2lf",s);
  
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值