2016年第七届蓝桥杯C/C++ A组国赛 —— 第三题:打靶
生活随笔
收集整理的這篇文章主要介紹了
2016年第七届蓝桥杯C/C++ A组国赛 —— 第三题:打靶
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
打靶
小明參加X星球的打靶比賽。
比賽使用電子感應(yīng)計(jì)分系統(tǒng)。其中有一局,小明得了96分。
這局小明共打了6發(fā)子彈,沒有脫靶。
但望遠(yuǎn)鏡看過去,只有3個(gè)彈孔。
顯然,有些子彈準(zhǔn)確地穿過了前邊的彈孔。
不同環(huán)數(shù)得分是這樣設(shè)置的:
1,2,3,5,10,20,25,50
那么小明的6發(fā)子彈得分都是多少呢?有哪些可能情況呢?
下面的程序解決了這個(gè)問題。
仔細(xì)閱讀分析代碼,填寫劃線部分缺失的內(nèi)容。
注意:只填寫劃線處缺少的內(nèi)容,不要填寫已有的代碼或符號(hào),也不要填寫任何解釋說明文字等。
Code
/*^....0^ .1 ^1^.. 011.^ 1.0^ 1 ^ ^0.11 ^ ^..^0. ^ 0^.0 1 .^.1 ^0 .........001^.1 1. .111100....01^00 11^ ^1. .1^1.^ ^0 0^.^ ^0..1.1 1..^1 .0 ^ ^00. ^^0.^^ 0 ^^110.^0 0 ^ ^^^10.01^^ 10 1 1 ^^^1110.101 10 1.1 ^^^1111110010 01 ^^ ^^^1111^1.^ ^^^10 10^ 0^ 1 ^^111^^^0.1^ 1....^11 0 ^^11^^^ 0.. ....1^ ^ ^1. 0^ ^11^^^ ^ 1 111^ ^ 0.10 00 11 ^^^^^ 1 0 1.0^ ^0 ^0 ^^^^ 0 0.0^ 1.0 .^ ^^^^ 1 1 .0^.^ ^^ 0^ ^1 ^^^^ 0. ^.11 ^ 11 1. ^^^ ^ ^ ..^^..^ ^1 ^.^ ^^^ .0 ^.00..^ ^0 01 ^^^ .. 0..^1 .. .1 ^.^ ^^^ 1 ^ ^0001^ 1. 00 0. ^^^ ^.0 ^.1. 0^. ^.^ ^.^ ^^^ ..0.01 .^^. .^ 1001 ^^ ^^^ . 1^. ^ ^. 11 0. 1 ^ ^^ 0.0 ^. 0 ^0 1 ^^^ 0.0.^ 1. 0^ 0 .1 ^^^ ...1 1. 00 . .1 ^^^ ..1 1. ^. 0 .^ ^^ ..0. 1. .^ . 0 ..1 1. 01 . . ^ 0^.^ 00 ^0 1. ^ 1 1.0 00 . ^^^^^^ ..^ 00 01 ..1. 00 10 1 ^^.1 00 ^. ^^^ .1.. 00 .1 1..01 ..1.1 00 1. ..^ 10^ 1^ 00 ^.1 0 1 1.1 00 00 ^ 1 ^. 00 ^.^ 10^ ^^1.1 00 00 10^..^ 1. ^. 1.0 1 ^. 00 00 .^^ ^. ^ 1 00 ^0000^ ^ 011 0 ^. 00.0^ ^00000 1.00.1 11. 1 0 1^^0.01 ^^^ 01.^ ^ 1 1^^ ^.^1 1 0... 1 ^1 1^ ^ .01 ^ 1.. 1.1 ^0.0^ 0 1..01^^100000..0^1 1 ^ 1 ^^1111^ ^^0 ^ ^ 1 1000^.1 ^.^ . 00.. 1.1 0. 01. . 1. .^1. 1 1. ^0^ . ^.1 00 01^.0 001. .^*/ // VB_king —— 2016_Finals_A_C++.cpp created by VB_KoKing on 2019-05-13:08. /* Procedural objectives:Variables required by the program:Procedural thinking:Functions required by the program:Determination algorithm:Determining data structure:*/ /* My dear Max said: "I like you, So the first bunch of sunshine I saw in the morning is you, The first gentle breeze that passed through my ear is you, The first star I see is also you. The world I see is all your shadow."FIGHTING FOR OUR FUTURE!!! */ #include <stdio.h> #define N 8void f(int ta[], int da[], int k, int ho, int bu, int sc) {int i,j;if(ho<0 || bu<0 || sc<0) return;if(k==N){if(ho>0 || bu>0 || sc>0) return;for(i=0; i<N; i++){for(j=0; j<da[i]; j++)printf("%d ", ta[i]);}printf("\n");return;}for(i=0; i<=bu; i++){da[k] = i; // f(ta, da, k+1, _____________ , bu-i, sc-ta[k]*i); //填空位置f(ta, da, k+1, ho-(i>0?1:0), bu-i, sc-ta[k]*i); //填空位置}da[k] = 0; }int main() {int ta[] = {1,2,3,5,10,20,25,50};int da[N];f(ta, da, 0, 3, 6, 96); /** f(int ta[], int da[], int k, int ho, int bu, int sc)* ta[]是八種分?jǐn)?shù)* k* ho表示三個(gè)彈孔* bu表示六發(fā)子彈* sc表示最終成績*/return 0; }總結(jié)
以上是生活随笔為你收集整理的2016年第七届蓝桥杯C/C++ A组国赛 —— 第三题:打靶的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2013年第四届蓝桥杯C/C++ A组国
- 下一篇: 2016年第七届蓝桥杯 - 国赛 - J