山东大学程序设计思维学习笔记作业11

A.11-1

在这里插入图片描述
Sample Input
50 10
Sample Output
8
思路:循环,一个等差一个等比,没什么好说的

//
// Created by haofeng on 4/29/20.
//
#include <iostream>
#include <algorithm>
using namespace std;
double K;
double N;
double Eps=0.001;
int main(){
   
    cin>>N>>K;
    double totalN=N;
    double totalK=200;
    int year=0;
    for (int i = 1; i <= 20; ++i) {
   
        //cout<<totalN<< "    "<<totalK<<endl;
        if(abs(totalN-totalK)<Eps||totalN>totalK){
   
            year=i;
            break;
        }
        totalN+=N;
        totalK*=(1+K/100);
    }
    if(year==0){
   
        cout<<"Impossible";
    }
    else{
   
        cout<<year;
    }
}

B.11-2

在这里插入图片描述
Sample Input
4
0 0 0 0
0 0 0 0
0 1 0 0
0 0 0 0
0 0 0 0
0 1 0 0
0 0 0 0
0 0 0 0
Sample Output
1

思路:把顺时针的过程描述出来即可,因为要来回转注意储存问题

//
// Created by haofeng on 4/29/20.
//
#include <iostream>
using namespace std;
int n;
int N[20][20];
int M[20][20];
int HOPE[20][20];
bool same(int m0n){
   
    if(m0n==0) {
   //用n判断
        for (int i = 0; i < n; ++i) {
   
            for (int j = 0; j < n; ++j) {
   
                if (N[i][j] != HOPE[i][j]) {
   
                    return false;
                }
            }
        }
    } else{
   //用m判断
        for (int i = 0; i < n; ++i) {
   
            for (int j = 0; j < n; ++j) {
   
                if (M[i][j] != HOPE[i][j]) {
   
                    return false;
                }
            }
        }
    }
    return true;
}
void turn(int n2m){
   
    if 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值