[程序猿初养成]Coursera-C程序设计进阶-第二周作业-编程题#6

NOI2.3.6262 流感传染题解(C++) 题目 总Time Limit: 1000ms Memory Limit: 65536kB Description 有一批易感人群住在网格状的宿舍区内,宿舍区为n*n的矩阵,每个格点为一个房间,房间里可能住人,也可能空着。在第一天,有些房间里的人得了流感,以后每天,得流感的人会使其邻居传染上流感,(已经得病的不变),空房间不会传染。请输出第m天得流感的人数。 Input 第一行一个数字n,n不超过100,表示有n*n的宿舍房间。 接下来的n行,每行n个字符,’.’表示第一天该房间住着健康的人,’#’表示该房间 阅读详情

编程题#6:流感传染

注意: 总时间限制: 1000ms 内存限制: 65536kB

描述

有一批易感人群住在网格状的宿舍区内,宿舍区为n*n的矩阵,每个格点为一个房间,房间里可能住人,也可能空着。在第一天,有些房间里的人得了流感,以后每天,得流感的人会使其邻居传染上流感,(已经得病的不变),空房间不会传染。请输出第m天得流感的人数。

输入

第一行一个数字n,n不超过100,表示有n*n的宿舍房间。

接下来的n行,每行n个字符,’.’表示第一天该房间住着健康的人,’#’表示该房间空着,’@’表示第一天该房间住着得流感的人。

接下来的一行是一个整数m,m不超过100.

输出

输出第m天,得流感的人数

样例输入

5
....#
.#.@.
.#@..
#....
.....
4

样例输出

16

//
//  main.cpp
//  test
//
//  Created by SpyThree on 16/9/16.
//  Copyright © 2016年 SpyThree. All rights reserved.
//

#include <iostream>
#include <iomanip>
using namespace std;

int n;
int m;
char matrix[10000][10000];
char temp[10000][10000];


void get_Infected(int i, int j);
bool occupied_OrNot(int i, int j);
int count();


int main (){

    
    cin >> n;
    
    
    for (int i = 0; i < n; i ++) {
        for (int j = 0; j < n; j ++) {
            cin >> matrix[i][j];
        }
    }
    
    cin >> m;
    

    for (int t = 0; t < m - 1; t ++) {
        
        
        for (int i = 0; i < 10000; i ++) {
            for (int j = 0; j < 10000; j ++) {
                temp[i][j] = matrix[i][j];
            }
        }
        
        for (int i = 0; i < n; i ++) {
            for (int j = 0; j < n; j ++) {
                if (matrix[i][j] == '@') {
                    get_Infected(i, j);
                }
            }
        }
        
        for (int i = 0; i < 10000; i ++) {
            for (int j = 0; j < 10000; j ++) {
                matrix[i][j] = temp[i][j];
            }
        }
        
    }
    
    cout << count() <<endl;
    
    return 0;
}



void get_Infected(int i, int j){
    
    
    
    if (i == 0 && j == 0) {
        if (occupied_OrNot(1, 0) == true) {
            temp[1][0] = '@';
        }
        if (occupied_OrNot(0, 1) == true) {
            temp[0][1] = '@';
        }
    }
    
    if (i == 0 && j != 0 && j != n - 1) {
        if (occupied_OrNot(0, j - 1) == true) {
            temp[0][j - 1] = '@';
        }
        if (occupied_OrNot(0, j + 1) == true) {
            temp[0][j + 1] = '@';
        }
    }
    
    if (i == 0 && j == n - 1) {
        if (occupied_OrNot(0, n - 2) == true) {
            temp[0][n - 2] = '@';
        }
        if (occupied_OrNot(1, n - 1) == true) {
            temp[1][n - 1] = '@';
        }
    }

    if (i != 0 && j == n - 1 && i != n - 1) {
        if (occupied_OrNot(i, n - 1) == true) {
            temp[i][n - 1] = '@';
        }
        if (occupied_OrNot(i, n + 1) == true) {
            temp[i][n + 1] = '@';
        }
    }
        
    if (i == n - 1 && j == n - 1) {
        if (occupied_OrNot(n - 1, n - 2) == true) {
            temp[n - 1][n - 2] = '@';
        }
        if (occupied_OrNot(n - 2, n - 1) == true) {
            temp[n - 2][n - 1] = '@';
        }
    }
        
    if (j != 0 && j != n - 1 && i == n - 1) {
        if (occupied_OrNot(n - 1, j + 1) == true) {
            temp[n - 1][j + 1] = '@';
        }
        if (occupied_OrNot(n - 1, j - 1) == true) {
            temp[n - 1][j - 1] = '@';
        }
    }

    if (i == n - 1 && j == 0) {
        if (occupied_OrNot(n - 1, 1) == true) {
            temp[n - 1][1] = '@';
        }
        if (occupied_OrNot(n - 2, 0) == true) {
            temp[n - 2][0] = '@';
        }
    }
        
    if (i != 0 && i != n - 1 && j == 0) {
        if (occupied_OrNot(i - 1, 0) == true) {
            temp[i - 1][0] = '@';
        }
        if (occupied_OrNot(n - 1, j - 1) == true) {
            temp[i + 1][0] = '@';
        }
    }
        
    if (i != 0 && i != n - 1 && j != 0 && j != n - 1) {
        if (occupied_OrNot(i - 1, j) == true) {
            temp[i - 1][j] = '@';
        }
        if (occupied_OrNot(i + 1, j) == true) {
            temp[i + 1][j] = '@';
        }
        if (occupied_OrNot(i, j + 1) == true) {
            temp[i][j + 1] = '@';
        }
        if (occupied_OrNot(i, j - 1) == true) {
            temp[i][j - 1] = '@';
        }
    }

}


bool occupied_OrNot(int i, int j){
    if (matrix[i][j] != '#') {
        return true;
    }else{
        return false;
    }
}


int count(){
    int result = 0;
    for (int i = 0; i < n; i ++) {
        for (int j = 0; j < n; j ++) {
            if (matrix[i][j] == '@') {
                result = result + 1;
            }
        }
    }
    return result;
}

这一题思路还算比较明确吧,但是写起来很麻烦,我觉得这几句代码挺有用的,在做声音、流感传播的时候非常有用,需要mark一下


[程序猿初养成]Coursera-C程序设计进阶-第二周作业-编程题#5 编程题#5:细菌实验分组 注意: 总时间限制: 1000ms 内存限制: 65536kB 描述 有一种细菌分为A、B两个亚种,它们的外在特征几乎完全相同,仅仅在繁殖能力上有显著差别,A亚种繁殖能力非常强,B亚种的繁殖能力很弱。在一次为时一个 小时的细菌繁殖实验中,实验员由于疏忽把细菌培养皿搞乱了,请你编写一个程序,根据实验结果,把两个亚种的培养皿重新分成两组。 阅读详情

相关推荐

【信奥赛一本通】1191:流感传染(详细代码)

数组练习第1题:陶陶摘苹果 :陶家的院子里有一棵苹果树,每到秋天树上就会结出10个苹果。苹果成熟的时候,陶陶就会跑去摘苹果。陶陶有个30厘米高的板凳,当她不能直接用手摘到苹果的时候,就会踩到板凳上再试试。现在已知10个苹果到地面的高度,以及陶陶把手伸直的时候能够达到的最大高度,请帮陶陶算一下她能够摘到的苹果的数目。假设她碰到苹果,苹果就会掉下来。1.题目2.代码 1.题目 【题目描述】 陶陶家的院子里有一棵苹果树,每到秋天树上就会结出10个苹果。苹果成熟的时候,陶陶就会跑去摘苹果。陶陶有个30厘米高的板凳,

qq_40802813的博客 1610

流感传染

【题目描述】 有一批易感人群住在网格状的宿舍区内,宿舍区为n*n的矩阵,每个格点为一个房间,房间里可能住人,也可能空着。在第一天,有些房间里的人得了流感,以后每天,得流感的人会使其邻居传染上流感,(已经得病的不变),空房间不会传染。请输出第m天得流感的人数。 【输入】 第一行一个数字n,n不超过100,表示有n*n的宿舍房间。 接下来的n行,每行n个字符,’.’表示第一天该房间住着健康的人,’#’表示该房间空着,’@’表示第一天该房间住着得流感的人。 接下来的一行是一个整数m,m不超过100。 【输出】 输

lyc_lb 1122

信息学奥赛一本通C++语言——1191:流感传染

【题目描述】 有一批易感人群住在网格状的宿舍区内,宿舍区为n*n的矩阵,每个格点为一个房间,房间里可能住人,也可能空着。在第一天,有些房间里的人得了流感,以后每天,得流感的人会使其邻居传染上流感,(已经得病的不变),空房间不会传染。请输出第m天得流感的人数。 【输入】 第一行一个数字n,n不超过100,表示有n*n的宿舍房间。 接下来的n行,每行n个字符,’.’表示第一天该房间住着健康的人,’#’...

子航OIer 1698

202312C语言3级真题

有一批易感人群住在网格状的宿舍区内,宿舍区为n*n的矩阵,每个格点为一个房间,房间里可能住人,也可能空着。在第一天,有些房间里的人得了流感,以后每天,得流感的人会使其邻居传染上流感,(已经得病的不变),空房间不会传染。请输出第m天得流感的人数。第一行一个数字n,n不超过100,表示有n*n的宿舍房间。接下来的n行,每行n个字符,’.’表示第一天该房间住着健康的人,’#’表示该房间空着,’@’表示第一天该房间住着得流感的人。输出第m天,得流感的人数。内存限制:65536。

ybq_sc的博客 893

【星火】海思HI3516C开发板实战:基于LVGL与MPP库的行车记录仪/电子显微镜方案

本文详细介绍了基于海思HI3516CV500开发板,结合LVGL图形库与海思MPP媒体处理平台,实现行车记录仪与电子显微镜方案的完整实战过程。内容涵盖从系统环境搭建、驱动配置到应用开发的全流程,重点解析了MPP视频流处理管道与LVGUI界面协同工作的核心机制,为嵌入式音视频开发提供了可复用的参考方案。

weixin_42126677的博客 166

嵌入式C开发必备:用Cursor规则搞定代码风格检查(附Pikachu项目实战)

本文以Pikachu开源项目为例,详细介绍了如何利用Cursor的AI代理规则系统,为嵌入式C开发项目配置一套完整的代码风格检查与规范执行方案。通过实战演示,指导开发者创建项目级规则,实现命名、格式、硬件抽象层及驱动开发的自动化规范,从而提升代码一致性、可维护性和团队协作效率。

weixin_29181861的博客 607

leetcode 941. 有效的山脉数组

给定一个整数数组 A,如果它是有效的山脉数组就返回 true,否则返回 false。 让我们回顾一下,如果 A 满足下述条件,那么它是一个山脉数组: A.length >= 3 在 0 < i < A.length - 1 条件下,存在 i 使得: A[0] < A[1] < … A[i-1] < A[i] A[i] > A[i+1] > … > A[A.length - 1] 示例 1: 输入:[2,1] 输出:false 代码 class Solut

weixin_44560620的博客 235

【无标题】EXCEL实现刷题

运用Excel开发的刷题工具,具有普遍实用性,可将WORD的试题自动导入并实现刷题。

weixin_44081794的博客 2983

[程序猿初养成]Coursera-C程序设计进阶-第二周作业-编程题#2

编程题#2:四大湖 注意: 总时间限制: 1000ms 内存限制: 65536kB 描述 我国有4大淡水湖。 A说:洞庭湖最大,洪泽湖最小,鄱阳湖第三。 B说:洪泽湖最大,洞庭湖最小,鄱阳湖第二,太湖第三。 C说:洪泽湖最小,洞庭湖第三。 D说:鄱阳湖最大,太湖最小,洪泽湖第二,洞庭湖第三。 已知这4个湖的大小均不相等,4个人每人仅答对一个,

spythree的博客 1784

保姆级教程:在爱快iKuai虚拟机里装OpenWrt旁路由,实现去广告和特殊功能

本文提供在爱快iKuai虚拟机中安装OpenWrt旁路由的详细教程,帮助用户实现去广告和特殊功能扩展。通过分步指导,包括虚拟机配置、网络设置和功能优化,打造稳定高效的家庭网络环境,特别适合软路由爱好者和网络管理员。

weixin_31364787的博客 874

解密 vn.py 源码:从事件驱动到模块化设计的实战解析

本文深入解析vn.py源码,重点剖析其事件驱动机制与模块化设计。通过事件引擎、处理器字典等核心组件分析,展示如何实现低耦合高内聚的交易系统架构,并结合实战案例说明模块化设计带来的开发效率提升。文章还详细解读了Gateway抽象层、核心数据结构及设计模式应用,为量化交易开发者提供源码级实践指南。

weixin_27427619的博客 255

[程序猿初养成]Coursera-C程序设计进阶-第二周作业-编程题#1

编程题#1:寻找下标 注意: 总时间限制: 1000ms 内存限制: 65536kB 描述 已知一个整数数组x[],其中的元素彼此都不相同。找出给定的数组中是否有一个元素满足x[i]=i的关系,数组下标从0开始。 举例而言,如果x[]={-2,-1,7,3,0,8},则x[3] = 3,因此3就是答案。 输入 第一行包含一个整数n (0 第二行包

spythree的博客 840

C++性能优化:深入理解缓存一致性与伪共享

在现代多核处理器的世界里,理解缓存一致性和伪共享就像理解一个复杂社会系统的运作规则。正如心理学家阿德勒所说:"人的行为总是有目的的",CPU缓存的每一次同步也都有其深层的硬件逻辑。本文将带你深入探索这些看不见的性能杀手,以及如何在实际项目中与它们优雅共处。

探索C++编程的奥秘,分享深入的技术见解和实践,旨在激发读者创造力与解决问题的思维。 939

[程序猿初养成]Coursera-C程序设计进阶-第二周作业-编程题#4

编程题#4:Tomorrow never knows? 来源: POJ (Coursera声明:在POJ上完成的习题将不会计入Coursera的最后成绩。) 注意: 总时间限制: 1000ms 内存限制: 65536kB 描述 甲壳虫的《A day in the life》和《Tomorrow never knows》脍炙人口,如果告诉你a day in the l

spythree的博客 1132

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

[程序猿初养成]Coursera-C程序设计进阶-第二周作业-编程题#3

编程题#3:发票统计 注意: 总时间限制: 1000ms 内存限制: 65536kB 描述 有一个小型的报账系统,它有如下功能: (1)统计每个人所报发票的总钱数 (2)统计每类发票的总钱数 将此系统简化为如下:假设发票类别共有A、B、C三种;一共有三个人,ID分别为1、2、3。 输入 系统输入包含三行,每行第一个数为人员ID(整型,1或2或

spythree的博客 985

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

流感传染(信息学奥赛一本通)

题目描述 有一批易感人群住在网格状的宿舍区内,宿舍区为 n × n 的矩阵,每个格点为一个房间,房间里可能住人,也可能空着。 在第一天,有些房间里的人得了流感,以后每天,得流感的人会使其邻居传染上流感(已经得病的不变),空房间不会传染。 请输出第 m 天得流感的人数。 输入格式 第一行一个数字 n,n 不超过100,表示有 n × n 的宿舍房间。 接下来的 n 行,每行 n 个字符,. 表示第一天该房间住着健康的人,# 表示该房间空着,@ 表示第一天该房间住着得流感的人。 接下来的一行是一个整数 m,m

六级不考550+不改名 1616

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

一本通题解——1191:流感传染

题目相关 题目链接 一本通 OJ,http://ybt.ssoier.cn:8088/problem_show.php?pid=1191。 题目描述 有一批易感人群住在网格状的宿舍区内,宿舍区为 n*n 的矩阵,每个格点为一个房间,房间里可能住人,也可能空着。在第一天,有些房间里的人得了流感,以后每天,得流感的人会使其邻居传染上流感,(已经得病的不变),空房间不会传染。请输出第 m 天得流...

努力中的老周的专栏 1893

时钟

题目内容: 在课程所给的时钟程序的基础上修改。 这一周的编程题是需要你在课程所给的时钟程序的基础上修改而成。但是我们并不直接给你时钟程序的代码,请根据视频自己输入时钟程序的Display和Clock类的代码,然后来做这个题目。 我们需要给时钟程序加上一个表示秒的Display,然后为Clock增加以下public的成员函数: public Clock

weixin_38508043的博客 742

一本通:1191流感传染

一本通:流感传染 【题目描述】 有一批易感人群住在网格状的宿舍区内,宿舍区为n*n的矩阵,每个格点为一个房间,房间里可能住人,也可能空着。在第一天,有些房间里的人得了流感,以后每天,得流感的人会使其邻居传染上流感,(已经得病的不变),空房间不会传染。请输出第m天得流感的人数。 【输入】 第一行一个数字n,n不超过100,表示有n*n的宿舍房间。 接下来的n行,每行n个字符,’.’表示第一天该房间住...

聽竹風的博客 3120

C++三级专项 流感传染

有一批易感人群住在网格状的宿舍区内,宿舍区为n*n的矩阵,每个格点为一个房间,房间里可能住人,也可能空着。在第一天,有些房间里的人得了流感,以后每天,得流感的人会使其邻居传染上流感,(已经得病的不变),空房间不会传染。第一行一个数字n,n不超过100,表示有n*n的宿舍房间。接下来的n行,每行n个字符,’.’表示第一天该房间住着健康的人,’#’表示该房间空着,’@’表示第一天该房间住着得流感的人。接下来的一行是一个整数m,m不超过100。输出第m天,得流感的人数。内存限制:65536。

msn_feng023的博客 775

1344: 【递推】【入门】流感传染

有一批易感人群住在网格状的宿舍区内,宿舍区为n*n的矩阵,每个格点为一个房间,房间里可能住人,也可能空着。在第一天,有些房间里的人得了流感,以后每天,得流感的人会使其邻居传染上流感,(已经得病的不变),空房间不会传染。请输出第m天得流感的人数。接下来的n行,每行n个字符,’.’表示第一天该房间住着健康的人,’#’表示该房间空着,’@’表示第一天该房间住着得流感的人。第一行一个数字n,n不超过100,表示有n*n的宿舍房间。接下来的一行是一个整数m,m不超过100。输出第m天,得流感的人数。

yangrenrui的博客 1990

1191:流感传染

题目 1191:流感传染 时间限制: 1000 ms 内存限制: 65536 KB 【题目描述】 有一批易感人群住在网格状的宿舍区内,宿舍区为n*n的矩阵,每个格点为一个房间,房间里可能住人,也可能空着。在第一天,有些房间里的人得了流感,以后每天,得流感的人会使其邻居传染上流感,(已经得病的不变),空房间不会传染。请输出第m天得流感的人数。 【输入】 第一行一个数字n,n不超过100,表示有n*n的宿舍房间。 接下来的n行,每行n个字符,’.’表示第一天该房间住着健康的人,’#’表示该房间空

[PE]经典八炮的博客 812
上一篇: [程序猿初养成]Coursera-C程序设计进阶-第二周作业-编程题#5
spythree
博客等级 码龄10年 1粉丝 8原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址