UV 11743-credit check

Source: Internet
Author: User

Question: Determine whether the card number is valid. Give you four groups of four digits, two times the digits of the even number and the sum of the odd digits to determine whether the ending number is 0.

Analysis: simple question and simulation. You just need to judge based on the proposal.

Note: Question 460, come on!

# Include <iostream> # include <cstdlib> using namespace STD; char data [4] [5]; int main () {int N; while (CIN> N) for (INT I = 1; I <= N; ++ I) {for (INT I = 0; I <4; ++ I) CIN> data [I]; int D = 0, u = 0, T = 0; For (INT I = 0; I <4; ++ I) {T = (data [I] [0]-'0') * 2; D + = (T/10 + T % 10 ); U + = (data [I] [1]-'0'); t = (data [I] [2]-'0') * 2; d + = (T/10 + T % 10); U + = (data [I] [3]-'0');} If (D + U) % 10) cout <"invalid" <Endl; else cout <"valid" <Endl;} return 0 ;}

UV 11743-credit check

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.