C. Enter a number to remove the number containing 7 and the number divisible by 7.

Source: Internet
Author: User

C. Enter a string of numbers to remove the number containing 7 and the number divisible by 7. Each number is less than 10000, and the number is less than 100.

Input example :,

Output: 1, 2, 45

Note: The number of inputs is uncertain, so it cannot be processed using an integer array. It cannot end with an integer array element equal to \ n, because the array is an integer and \ n is a random type, it cannot be entered.

So we need to use strings for processing. We first take out all integers separated by commas, and then judge and output these numbers.


# Include <stdio. h>
# Include <string. h>
Void main ()
{
Char A [1000000];
Int B [100], C [100];
Int I, J, K, Len, T, flag = 0, len1 = 0;
K = 0; Len = 0; t = 0;
Gets ();
Len1 = strlen ();
For (I = 0, j = 0;I <=Len1; I ++)
If (A [I]> = '0' & A [I] <= '9 ')
{
T = 10 * t + A [I]-'0 ';
Flag = 1;
}
Else if (flag = 0)
Continue;
Else
{
B [J] = T;
J ++;
Len ++;
T = 0;
Flag = 0;
}


For (j = 0, I = 0; I <Len; I ++)
If (B [I] % 7 = 0) continue;
Else if (B [I] % 10 = 7) continue;
Else if (B [I]/10) % 10 = 7) continue;
Else if (B [I]/100) % 10 = 7) continue;
Else if (B [I]/1000) % 10 = 7) continue;
Else
{
C [J] = B [I];
J ++;
}
For (I = 0; I <J-1; I ++)
Printf ("% d,", C [I]);
Printf ("% d \ n", C [J-1]);
}

Related Article

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.