藍橋杯 BASIC-1~3 閏年判斷、01子串、字母圖形,basic-101子

來源:互聯網
上載者:User

藍橋杯 BASIC-1~3 閏年判斷、01子串、字母圖形,basic-101子

閏年判斷

【AC代碼】:

#include <iostream>#include <algorithm>using namespace std;int main(){int y = 0;cin >> y;if (((0==y%4)&&(0!=y%100))||(0==y%400))cout << "yes";elsecout << "no";}

01子串

【AC代碼】:方法很多,最簡單的。

#include <iostream>#include <algorithm>using namespace std;int main(){int i, j, k, m, n;for (i = 0; i < 2; i++){for (j = 0; j < 2; j++){for (k = 0; k < 2; k++){for (m = 0; m < 2; m++){for (n = 0; n < 2; n++)cout << i << j << k << m << n << endl;}}}}}


字母圖形

【AC代碼】:可以以每個A為基準。

#include <iostream>#include <algorithm>using namespace std;#define MAX 26+1int main(){char gra[MAX][MAX];int n = 0, m = 0, t = 0;int i = 0, j = 0;;cin >> n >> m;t = m>n?n:m;for (i = 0; i < t; i++){gra[i][i] = 'A';for (j = i+1; j < m; j++)gra[i][j] = 'A'+j-i;for (j = i+1; j < n; j++)gra[j][i] = 'A'+j-i;}for (i = 0; i < n; i++){for (j = 0; j < m; j++)cout << gra[i][j];cout << endl;}}



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.