Idea + code 1039 buy or not buy (20 points) (C language)

Idea: This question is traversal, but you must pay attention to a problem: abcde aa If these two arrays, first take out the second character The first letter a of the string is compared with the letter of the first string in turn, but note that if you continue to traverse with the second letter a in the second string, you will find that it will succeed again, but obviously Is not right, so we use the space " " instead of the first string to traverse successful letters, such as a string after the first traversal becomes:

"空间bcde" Then traverse.

小红 wants to buy some beads to make a string of beads that you like. The seller who sells the beads has a lot of colorful beads, but refuses to sell any strings. So Xiaohong wants you to help judge whether a certain bead contains all the beads you want? If so, tell her how many extra beads there are; if not, tell her how many beads are missing.

For convenience, we use the characters in the range [0-9], [a-z], [A-Z] to represent the color. For example, in Figure 1, the third string is the bead string that Xiaohong wants to make; then the first string can be bought, because it contains all the beads she wants, and there are 8 more unwanted beads; the second string cannot be bought. Because there are no black beads and a red bead is missing.



Input format:

Each input contains 1 test case. Each test case gives the bead string of the stall owner and the bead string that Xiaohong wants to do in two rows, and the two strings do not exceed 1000 beads.

Output format:

If you can buy, output Yes in one line and how many extra beads there are; if you can't buy it, output No in one line and how many beads are missing. It is separated by 1 space.

入样样 1:


出样样 1:

Yes 8




No 2
#include <stdio.h>
#include <string.h>
Int main(){
Char str1[1001];
Char str2[1001];
Gets(str2); //Enter
Int i=0, j=0, f=0, count=0;
Str1[j]=' '; //replace with a space

If(count!=strlen(str2)&&i==strlen(str2)){ guarantees traversal completion


Printf("Yes %d",strlen(str1)-strlen(str2));
Printf("No %d",strlen(str2)-count);
Return 0;

strlen( ) is a function for calculating the length of a string, but to use it, you must write #include <string.h>

Summary: Any questions are welcome to point out, if you like, please pay attention. ~~