Blue Bridge Cup basic-4~6 sequence features, finding integers, Yang hui triangles

Source: Internet
Author: User

Sequence characteristics

"AC Code":

#include <iostream> #include <algorithm>using namespace std; #define MAX 10000+10int Main () {int n = 0, i = 0;int Num[max];cin >> n;for (i = 0; i < n; i++) cin >> num[i];int mmin = num[0], Mmax = num[0], sum = num[0];for (i = 1; i < n; i++) {if (Num[i]>mmax) Mmax = num[i];if (num[i]<mmin) mmin = num[i];sum + = Num[i];} cout << mmax << endl;cout << mmin << endl;cout << sum << Endl;}

Find integer

"AC Code": NOTE-1

#include <iostream> #include <algorithm>using namespace std; #define MAX 1000+10int Main () {int n = 0, x = 0, i = 0;int num[max];cin >> n;for (i = 0; i < n; i++) cin >> num[i];cin >> x;for (i = 0; i < n; i++) {if (Num[i] = = x) {cout << I+1;return 0;}} cout <<-1;}


Yang Hui Triangle

"AC Code": Must be initialized. There are no spaces at the end of the line.

#include <iostream> #include <algorithm> #include <cstdio> #include <cstring>using namespace STD; #define MAX 34+2int Main () {//freopen ("In.txt", "R", stdin);//freopen ("OUT.txt", "w", stdout); int n = 0, i = 0, j = 0;i NT Tra[max][max];cin >> n;//initial first colmemset (tra, 0, sizeof); for (i = 0; i < n; i++) tra[i][0] = 1;//f Illfor (i = 1; i < n; i++) {for (j = 1; j < MAX-1; J + +) {Tra[i][j] = Tra[i-1][j-1] + tra[i-1][j];}} Outputfor (i = 0; i < n; i++) {for (j = 0; J < N; j + +) {if (0! = Tra[i][j]) {if (0 = = j) cout << tra[i][j];elsec Out << "" << Tra[i][j];}} cout << Endl;}}



Blue Bridge Cup basic-4~6 sequence features, finding integers, Yang hui triangles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.