The article directories

    • 1, Hello World (5 分)
    • 2. Print the hourglass (20 points)
    • 3. Single-digit statistics (15 points)
    • 4. Calculate Celsius temperature (5 marks)
    • 5. Seat Number (15 points)
    • 6. Continuous factor (20 points)
    • 7, A-B (20 marks)
    • 8. Calculate the index (5 marks)
    • 9, Calculate the factorial and (10 marks)
    • 10, Simple questions (5 分)
    • 11. Square with Obama (15 points)
    • 12. Checking ID cards (15 points)
    • 13. How many are there (15 points)
    • 14. Big Ben (10 minutes)
    • Who will pour first (15 points)
    • 16. Too handsome to have any friends (20 points)
    • 17. Say important words three times (5 marks)
    • 18. Odd and Even split (10 points)
    • 19. Output GPLT (20 points)
    • 20, The day after tomorrow (5 marks)
    • 21, A+B (15 分)
    • 22, I Love GPLT (5 分)
    • 23. Rent (20 points)
    • 24. Are you too fat (5 points)
    • 25. A gang of one (15 points)
    • 26. Are you too fat? (10 points)
    • 27, Left pad (20 points)
    • 28. Year of Birth (15 points)
    • 29. Thumbs up (20 points)
    • 30. Valentine’s Day (15 points)
    • 31, A times B (5 marks)
    • 32, A divided by B (10 marks)
    • 33. New World (5 points)
    • 34. Ancient Style layout (20 points)
    • 35. Best Height difference between couples (10 points)
    • 36. Looking for 250 (10 points)
    • 37. Date formatting (5 marks)
    • Reading Room (20 points)
    • 39. Sure win (15 points)
    • 40, the universe is invincible hello (5 points)
    • 41. Single (20 points)
    • 42. Pretending to sleep (10 points)
    • 43, MATRIX A times B (15 marks)
    • 44, the NTH string (15 points)
    • 45. Discount (5 points)
    • 46. 2018 We need to win (5 points)
    • 47. Electron Wang (10 points)
    • 48. Who is the winner (10 points)
    • 49. De-weighting linked lists (25 points)
    • 50. Hall of Fame and Vouchers (25 points)
    • 51. Make small change (30 cents)
    • 52. (3n+1) Guess (15 points)
    • 53, Write this number (20 marks)
    • I want to pass! (20 points)
    • 55, Change the format of output integer (15 marks)
    • 56. Prime Pair Conjecture (20 points)
    • 57. Problem with loop right shift of array elements (20 points)
    • 58. Being sarcastic (20 points)
    • 59, The Derivative of a Unary Polynomial (25 marks)
    • 60, A+B and C (15 分)
    • 61, Prime numbers (20 points)
    • 62, Theory of Moral ability (25 points)
    • A divided by B (20 marks)
    • 64. Hammer, Paper, Scissors (20 points)
    • 65. Moon cake (25 points)
    • 66. Single digit statistics (15 points)
    • 67、 D进制的A+B (20 分)
    • 68, The minimum number of groups (20 points)
    • 69, Check id card (15 points)
    • 70. Code with Obama (15 points)
    • 71. Stroke (15 points)
    • 72, The sum of the number of combinations (15 marks)
    • 73, True or false (15 points)
    • 74. Image Filtering (15 points)
    • 75. Wifi Password (15 points)
    • 76. Checking passwords (15 points)
    • 77. I won’t tell you (15 points)
    • 78, How many different values are there (20 points)
    • 79, Dangerous goods packing (25 points)
    • 80, N- Defensive number (15 points)
    • 81, Programming in C is fun! (5 points)
    • 82. Taxi Fare (15 points)
    • 83, Finding the Partial Sum of power Series Expansion (20 marks)
    • 84, What is a computer? (5 points)
    • 85. Assign x squared to Y (5 marks)
    • 86. Calculate the running time of the train (15 minutes)
    • 87, Calculate the salary (15 points)
    • 88, Day K candle picture (15 points)
    • 89. Are you too fat (10 points)
    • 90. Find the smallest string (15 points)
    • 91. Bubble sorting of Strings (20 points)
    • 92, The organization of the week information (10 points)
    • 93. Even and Odd (10 points)
    • 94. Pirates’ Spoils (25 points)
    • 95. Speeding judgment (10 points)
    • 96, JMU-DS – Order table interval element deletion (15 marks)
    • 97, Find the specified character (15 marks)
    • 98. Four Operations on complex numbers (15 points)
    • 99. Output triangle character array (15 points)
    • 100. Find the longest string (15 points)
    • 101, The classification of integers (20 points)
    • 102. Length of Service (20 points)
    • 103, 7-10 Array looping left (20 points)
    • Find the reciprocal KTH term of a chained linear list (20 marks)
    • 105, Square Circle to the right (20 points)
    • 106, The minimum number of groups (20 points)
    • 107. Monkeys eat peaches (15 points)
    • 108, String uppercase conversion (15 points)
    • 109. Calculation of piecewise Functions [3] (10 marks)
    • 110, Find integer (10 marks)
    • 111. Tourism Planning (25 points)
    • Number of Black Holes (20 points)
    • 113. The Hare and the Tortoise (20 points)
    • 114, Spiral square (20 points)
    • 115. Delete substrings from a string (20 points)
    • 116, A-B (20 points)
    • 117, Guess the number (20 points)
    • 118, 40059 Four Operations (15 points)
    • Who is the tallest in the dormitory (20 points)
    • 120. Stepped electricity price (15 points)
    • 121. Speedway penalties (15 points)
    • 122, catch the mouse ah ~ lost or earned? (20 points)
    • 123. Find a ball with a scale (10 points)
    • 124, Find the set of integers that meet the given conditions (15 marks)
    • 125. Count 24 points (25 points) with playing cards
    • 126, Approximate PI (15 marks)
    • 127. A Simple Calculator for Two Numbers (10 points)
    • 128, Introduction to Arithmetic: Addition, Subtraction, Multiplication and Division (10 marks)
    • 129, The NTH string (15 points)
    • 130. Calculating the value of a symbolic function (10 marks)
    • 12-24 hours (15 points)
    • 132. Grade Change (15 points)
    • Finding the number of combinations (15 marks)
    • 134. Output full array (20 points)
    • 135. Magic Coupon (25 points)
    • 136. Find the minimum value (20 points)
    • 137. Input and display of address book (10 points)
    • 138. Calculate how far an object falls (5 points)
    • 139. Time conversion (15 marks)
    • 140. Han Xin Points soldiers (10 points)
    • 141, BCD decryption (10 points)
    • 142. Number of traps (15 points)
    • 143. Simplified Insertion sort (15 points)
    • 144. Comparison of Rational Numbers (10 marks)
    • 145, Calculating the wages of employees (15 points)
    • 146. The Monkey chooses the King (20 points)
    • 147. Three digits in reverse order (10 points)
    • 148. Scoring Rules (5 points)
    • 149. Judges score (5 points)
    • 150, Sum of Special A Series (20 marks)
    • 151. Change coins (20 cents)
    • 152. Drop Ball (20 points)
    • 153, Output student scores (20 points)
    • 154, Find the number of digits and the sum of the digits (15 marks)
    • 155, The simplest fraction (15 marks)
    • 156. I am the Flag Raiser (10 points)
    • 157. RMB exchange (15 marks)
    • 158. Median of two ordered sequences (25 points)
    • 159. Find the student with the highest total score (15 points)
    • 160. Finding the Partial Sum of Simple Staggered Sequences with Given Precision (15 marks)
    • 161. Length of Words (15 marks)
    • 162. Table Output (5 marks)
    • 163. Packing Problems (20 points)
    • Find the first N terms of staggered sequence and (15 marks)
    • 165. Finding the mean square Deviation of Set Data (15 marks)
    • 166. Currency conversion (20 cents)
    • 167. Finding the Local Maximum of the Matrix (15 marks)
    • 168, Check the price of fruit (15 points)
    • 169. Mixed type data Formatting input (5 points)
    • 170, BCD decryption (10 marks)
    • 171. String Pattern Matching (25 points)
    • 179, Integers (5 分)
    • 173. PTA makes me refreshed (5 marks)
    • 174. Temperature conversion (5 marks)
    • 175. Output diamond pattern (5 marks)
    • 176. Fish or meat (10 points)

It’s not easy to make. Please give me a thumbs up if you like. I’m Wang Rui.

1, Hello World (5 分)

There’s no input for this super simple problem.

All you have to do is print the famous phrase “Hello World!” in one line. That’s it.

Example: None Example output: Hello World!

public class Main {
	public static void main(String[] args) {
		System.out.println("Hello World!"); }}Copy the code

2. Print the hourglass (20 points)

L1-002 Print an hourglass (20 marks) This question asks you to write a program to print the given symbol into the shape of an hourglass. For example, given 17 asterisks, print them in the following format





The hourglass shape is an odd number of symbols per line. Center alignment of line symbols; The difference between two adjacent lines is 2; The number of signs decreases to 1 and then increases from small to large. Equal number of symbols at the beginning and end.

Given any N symbols, it doesn’t necessarily make up exactly an hourglass. Ask that the printed hourglass use as many symbols as possible.

Input format: Each line contains a positive integer N (≤1000) and a symbol separated by a space.

Output format: First print out the largest hourglass shape made up of the given symbols, and finally print out the number of unused symbols in a line.

Input example: 19 * Output example:





2

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int i,j,k;		// for loop
		int n;			// There are several positive integers
		int b=1;		// Indicates the maximum number of rows
		int h=1;		// Count the rows
		int sum=1;		// At least 1 star will be printed
		int g=0;		// Determines the element to print Spaces
		int index;		// Remember the number of stars printed in the bottom half of the line
		String Str;		/ / symbol
		char c;
		Scanner dx = new Scanner(System.in);
		n = dx.nextInt();
		Str = dx.nextLine();	// Enter a string
		c = Str.charAt(1);		// Use the string-to-character method to get the character
		if(n<7) {
			System.out.println(c);
			System.out.println(n-1);
			System.exit(0);		// Request to terminate the JVM
		}
		else {
			while(sum<=n) {
				b = b+2;
				sum = sum + b*2;
				h++;
			}
		}
		h=h-1;		// Since K starts at 1, there will be one more line. Subtracting 1 is the true number of lines in the top and bottom half
		index = h;	// Protect the lower half of the line
		sum = sum - 2*b;	// Subtract the maximum number of rows on both sides, that is, the number of overcounts
		sum = n -sum;
		for(i=h; i>=1; i--)// Print the upper part [including the middle symbol]
		{
			for(j=1; j<=g; j++) System.out.print("");
			for(k=1; k<=2*i-1; k++) System.out.print(c); System.out.println(); g++; }for(i=2; i<=index; i++){for(j=1; j<=(g-2); j++){ System.out.print("");
			}
			for(k=1; k<=2*i-1;k++){
				System.out.print(c);
			}
			System.out.println();
			g--;
		}
		System.out.println(sum);
	}
}
Copy the code

3. Single-digit statistics (15 points)

L1-003 Unit digit statistics (15 minutes) Given a k-digit integer N= D k−1 10 K −1 +… + D 1 10 1 + D 0 (0≤ D I ≤9, I =0…, K −1, D k−1 >0), write a program to count the number of occurrences of each different unit digit. For example, given N=100311, there are two zeros, three ones, and one three.

Input format: Each input contains 1 test case, that is, a positive integer N with no more than 1000 digits.

Output format: For each different one digit in N, output the digit D and the number of times M in N in the format of D:M. The output is required in ascending order of D.

Example Input: 100311 Example output: 0:2 1:33 3:1

import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		int shu[] = new int[10];
		Scanner sc = new Scanner(System.in);
		String a = sc.nextLine();
		int len = a.length();
		for(int i = 0 ; i < len ; i++) {
			shu[a.charAt(i)-48] + +; }for(int i = 0 ; i < 10 ; i++) {
			if(shu[i]! =0)
				System.out.println(i+":"+shu[i]); }}}Copy the code

4. Calculate Celsius temperature (5 marks)

Given a temperature F in Fahrenheit, we need to write a program to calculate the temperature C in Celsius. The calculation formula is C=5 x (F−32)/9. The problem ensures that the input and output are within the range of integers.

Input format: Input gives a temperature in Fahrenheit in one line.

Output format: Output an integer value of Celsius in the format “Celsius = C”.

Example Value: 150 Output example value: Celsius = 65

import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
			Scanner scanner = new Scanner(System.in);
			int f = scanner.nextInt();
			System.out.println("Celsius = " + (5*(f-32) /9)); }}Copy the code

5. Seat Number (15 points)

Each PAT candidate will be assigned two seat numbers when taking the exam, one is a test seat and one is an exam seat. Under normal circumstances, the examinee first gets the test seat number when entering the test machine. After taking a seat and entering the test machine state, the system will display the examinee’s test seat number. During the test, the examinee needs to change to the test seat. But some candidates are late, the test machine has been over, they can only take the test machine seat number to ask you for help, from the background to find out their test seat number.

Input format: Enter the first line to give a positive integer N (≤1000), followed by N lines, each line gives a candidate’s information: admission ticket number Test seat number Test seat number. The admission ticket number consists of 16 digits and the seats are numbered from 1 to N. Ensure that each person’s admission ticket number is different and that at no time will two people be assigned to the same seat.

After the candidate information, a positive integer M (≤N) is given. The following line contains M test seat numbers to be queried, separated by Spaces.

Output format: Output the test ticket number and test seat number of each candidate in a line separated by a space.

Example: 4 3310120150912233 2 4 3310120150912119 4 1 3310120150912126 1 3 3310120150912002 3 23 4 Example: 3310120150912119 1 3310120150912002 2


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		HashMap map = new HashMap();
		while(--n>=0){
			String s=br.readLine();
			String s2[]=s.split("");
			map.put(s2[1],s2[0] +""+s2[2]);
		}
		int m=Integer.parseInt(br.readLine());
		String s3[]=br.readLine().split("");
		int j=0;
		while(--m>=0){ System.out.println(map.get(s3[j])); j++; }}}Copy the code

6. Continuous factor (20 points)

A positive integer N may have several consecutive numbers in its factors. For example, 630 can be decomposed into 3 x 5 x 6 x 7, where 5, 6, and 7 are three consecutive numbers. Given any positive integer N, it is required to write a program to find the number of the longest continuous factors and output the smallest sequence of continuous factors.

Input format: Input is given a positive integer N (1

Output format: First print the number of longest continuous factors in line 1; Then in line 2, factor 1, factor 2… * The format of factor k outputs the smallest sequential sequence of factors, where factors are printed in ascending order, excluding 1.

Input example: 630 Output example: 3 567

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		long n=s.nextInt();
		long start=0,len=0;
		long sum=0;
		for(int i=2; i<Math.sqrt(n); i++) { sum=1;
			for(intj=i; sum*i<=n; j++) { sum*=j;if(n%sum==0&&j-i+1>len) {
					start=i;
					len=j-i+1; }}}if(start==0) {
			start=n;
			len=1;
		}
		System.out.println(len);
		for(int i=0; i<len-1; i++) { System.out.print(start+i+"*");
		}
		System.out.print(start+len-1); }}Copy the code

7, A-B (20 marks)

They ask you to calculate A−B. The trouble is that both A and B are strings — that is, A−B is formed by removing all the characters contained in B from string A.

Input format: Input gives strings A and B in sequence on 2 lines. Both strings must be no longer than 10 or 4, and each string must consist of visible ASCII characters and whitespace characters, ending with a newline character.

Output format: Print the result string of A−B in one line.

Example: I love GPLT! It’s a fun game! Aeiou Example output: I LV GPLT! It ‘s fn gm!

#include<stdio.h>
#include<string.h>
int main(a)
{
	int i=0,j=0;			// For loops and array subscripts
	char str1[10010];		// Store two strings A and B
	char str2[10010];		// Used to store the string letters to be deleted
	int length;				// To store the length of a string
	gets(str1);
	gets(str2);
	length = strlen(str2);	// Just remember the length of the str2 string
	while(str1[i]! ='\ 0')	// start with str1
	{
		for(j=0; j<length; j++)// Put this letter in str2 and see if there is a corresponding letter, if there is a corresponding letter
		{					// Then the for loop will jump out prematurely, and j cannot be equal to length,
			if(str1[i]==str2[j])// Remember the key words in advance! So we can be sure from this that if the for loop executes
				break;			// At the end of the day, there is no corresponding letter in str2,
		}						// We need to display it.
		if(j==length)
			printf("%c",str1[i]);
		i++;
	}
	printf("\n");
	return 0;
}
	
Copy the code

8. Calculate the index (5 marks)

I’m telling you, this is the easy one — for any positive integer n up to 10, you’re asked to print 2 n. It is not difficult to you?

Input format: Input is given a positive integer n up to 10 in a line.

Output format: Output the value of 2 n in a line in the format 2^n =.

Input example: 5 Output example: 2^5 = 32 Author: Chen Yue Unit: Zhejiang University Time limit: 400 MS Memory limit: 64 MB

#include<stdio.h>
#include<math.h>
int main(a)
{
	int n;
	int result;
	scanf("%d",&n);
	if(n<1 || n>10)		return 0;
	result=pow(2,n);
	printf("2^%d = %d\n",n,result);
	return 0;
}
Copy the code

9, Calculate the factorial and (10 marks)

For a given positive integer N, you need to calculate S=1! + 2! + 3! +… +N! .

Input format: Input is given a positive integer N up to 10 in a line.

Output format: Outputs the value of S in a single line.

Input example: 3 Output example: 9 Author: Chen Yue Unit: Zhejiang University Time limit: 400 MS Memory limit: 64 MB

#include<stdio.h>
int main(a)
{
	int N;
	int i;	// for loop
	int sum=0,mix=1;	/ / sum
	scanf("%d",&N);
	if(N<1 || N>10)		return 0;
	for(i=1; i<=N; i++) { mix=i*mix; sum=sum+mix; }printf("%d\n",sum);
	return 0;
}
Copy the code

10, Simple questions (5 分)

I’m not kidding this time — there’s no input for this super simple question.

You just need to print the fact in one line: This is a simple problem. That’s it.

Input example: None Output example: This is a simple problem.

#include<stdio.h>
int main(a)
{
	printf("This is a simple problem.\n");
	return 0;
}
Copy the code

11. Square with Obama (15 points)

US President Barack Obama has become the first US President to write computer code, not only calling for everyone to learn to code, but even leading by example. In late 2014, to mark the official launch of Computer Science Education Week, Obama wrote simple computer code: Draw a square on a screen. Now you can draw with him!

Input format: Enter a line that gives the square edge length N (3≤N≤21) and some character C that makes up the square edge, separated by one space.

Output format: Prints the square drawn by the given character C. But notice that the spacing between rows is larger than the spacing between columns, so to make the result look more square, we actually output the number of rows as 50% of the number of columns (rounded).

Input example: 10 A Output example: AAAAAAAAAAAA AAAAAAAAAAAA AAAAAAAAAAAA aaAAAAAAAAAA

#include<stdio.h>
int main(a)
{
	int N;
	char c;
	int i,j;
	scanf("%d %c",&N,&c);
	if(N%2= =0) {for(i=0; i<N/2; i++){for(j=0; j<N; j++){printf("%c",c);
			}
				printf("\n"); }}else{
		for(i=0; i<N/2+1; i++){// Since the decimal point is always 0.5 anyway, add 1
			for(j=0; j<N; j++){printf("%c",c);
			}
			printf("\n"); }}return 0;
}
Copy the code

12. Checking ID cards (15 points)

L1-016 Verification of IDENTITY Card (15 points) A valid identity card number consists of 17 digits of the region, date and sequence numbers plus a one-digit verification code. The calculation rules of the verification code are as follows:

First, the first 17 digits are weighted and summed. The weight assignment is: {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; Then modulo the calculated sum with respect to 11 to get the value Z; Finally, the Z value and the check code M are corresponding according to the following relation:

Z: 0 1 2 3 4 5 6 7 8 9 10 M: 10 X 9 8 7 6 5 4 3 2 Now given some ID numbers, please verify the validity of the verification code and output the number in question.

Input format: The first line indicates that N (≤100) is the number of id numbers to be entered. Then N lines, each line gives an 18-digit ID number.

Output format: Output one problematic ID number in each line according to the input sequence. It does not check whether the first 17 bits are reasonable, but only whether the first 17 bits are all digits and the last 1 bit is calculated correctly. If All numbers are normal, All passed is displayed.

Example 1:4 320124198808240056 12010X198901011234 110108196711301866 37070419881216001X Example 1: 12010X198901011234 110108196711301866 37070419881216001X Example 2:2 320124198808240056 110108196711301862 Example 2: All passed

#include <stdio.h>  
#include <stdlib.h>  
   
int charToInt(char c)
{  
     return (int)(c-'0');  
 }  
 int main(int argc, char *argv[]) 
 {  
     int n,i,j,k=0,s,  
     a[]={7.9.10.5.8.4.2.1.6.3.7.9.10.5.8.4.2};  
     char cur,b[11] = {'1'.'0'.'X'.'9'.'8'.'7'.'6'.'5'.'4'.'3'.'2'},  
     c[20];  
     scanf("%d",&n);  
     for(i = 0; i < n; i++) { s=0;  
         scanf("%s",&c);  
         for(j= 0; j<17; j++) {if(c[j]>='0'&&c[j]<='9')
			 {  
                 s+=charToInt(c[j])*a[j];  
			 }
			 else
			 {  
                 printf("%s",c);  
                 if(i<n- 1)
				 {  
                     printf("\n");  
                 }  
                 s=- 1;  
                 break; }}if(b[s%11]==c[j]&&s! =- 1)
		 {  
             k++;  
         }
		 else if(b[s%11]! =c[j]&&s! =- 1)
		 {  
             printf("%s",c);  
             if(i<n- 1)
			 {  
                 printf("\n"); }}}if(k==n)
	 {  
         printf("All passed");  
     }  
     return 0;  
}  
Copy the code

13. How many are there (15 points)

An integer is defined as the ratio of the number of twos in it to the number of digits. If the number is negative, the degree increases by 0.5 times; If it’s still an even number, it doubles again. For example, the number 13142223336 is an 11-digit number with three 2’s, and it is both negative and even, so its degree of second offense is calculated as 3/11×1.5×2×100%, which is about 81.82%. Calculate how two a given integer is.

Input format: The first line of input gives an integer N with no more than 50 digits.

Output format: Output the degree of N in a line, with two decimal points reserved.

Thanks to Mr. Duan Xiaoyun of Anyang Normal University and Mr. Li Fulong of Software Engineering Class 5 for the supplementary test data!

#include<stdio.h>
#include<string.h>
int main(a)
{
	char N[50];
	int i;
	float count=0,sum=0; 
	scanf("%s",&N);
	int x=strlen(N);		// Calculates the length of the string
	for(i=0; i<x; i++){// Count how many twos there are
		if(N[i]=='2')
			count++;		
	}
	if(N[0] = =The '-') {/ / negative
			sum=(count/(x- 1)) *1.5*100;
	}else{						/ / positive
		sum=count/x*100;
	}
		if(N[x- 1] %2= =0)			/ / even
			sum*=2;
	printf("%.2f%%",sum);
	return 0;
}
Copy the code

14. Big Ben (10 minutes)

L1-018 Big Ben (10 minutes) A guy calling himself “Big Ben V” on Weibo urges farmers to take good care of their bodies and go to bed early by ringing the bell every day. However, because of his own work and rest is not very regular, so the bell does not ring regularly. Generally, the number of bells is determined according to the time of the bell. If it happens to be struck at a certain hour, the number of “when” is equal to the number of the hour. If the hour has passed, the next hour is struck. In addition, although there are 24 hours in a day, the clock only strikes 1~12 times in the second half of the day. For example, when the bell strikes at 23:00, it’s “knock knock knock knock knock knock knock knock knock”, while at 23:01, it’s “knock knock knock knock knock knock knock knock”. The clock does not strike between 00:00 midnight and 12:00 noon (endpoints included).

Please write a program, according to the current time for Big Ben bell.

Input format: The first line displays the current time in hh:mm format. Where hh is hour, between 00 and 23; Mm is minutes, between 00 and 59.

Output format: ring the bell for Big Ben according to the current time, that is, output the corresponding number of Dang in a line. If not, output:

Only hh:mm. Too early to Dang. Hh :mm is the input time.

Input the sample 1:19:05 output sample 1: DangDangDangDangDangDangDangDang input sample 2:07:05 output sample 2: Only 07:05. Too early to Dang.

#include<stdio.h>
main()
{
	int m, n,h,i,k;
	scanf("%d:%d", &m, &n);
	if (m >= 13 && m < 24)
	{
		h = m - 12;
		if(n ! =0)
			k = h + 1;
		else if (n == 0)
			k = h;

		for (i = 0; i < k; i++)
		{
			printf("Dang"); }}else
		printf("Only %02d:%02d. Too early to Dang.",m,n);
}
Copy the code

Who will pour first (15 points)

L1-019 Who pours first (15 points) is an interesting part of the ancient Chinese wine culture. The method that two people draw fist on wine table is: each mouth shout out a number, at the same time with hand draw out a number. If the sum of their numbers is exactly the same, the loser loses, and the loser is fined a drink. If two players win or two players lose, the next round continues until there is a single winner.

The following is the record of a and B’s drinking capacity (the maximum number of glasses they can drink without falling) and the record of pulling fists. Please judge which one of them will fall first.

Input format: Input the first line to give the amount of alcohol (not more than 100 non-negative integer) of both party A and party B, separated by Spaces. The next line gives a positive integer N (≤100), followed by N lines, each giving the record of a single stroke in the format:

A shout a row b shout B row where shout refers to the number shouted, row refers to the number drawn, both are positive integers not more than 100 (both hands row together).

Output format: Output the first person to fall in the first line: A for A, B for B. The second line tells you how many drinks the person who didn’t pour had. They guarantee that one of them will fall. Note that the program is terminated until someone falls down, and the following data need not be processed.

Example: 1 16 8 10 9 12 5 10 5 10 3 8 5 12 12 18 1 13 4 16 12 15 15 1 1 16 Example: A 1

#include<stdio.h>
int main(a)

{

	int N,A,B;		/ / A, B

	int i;

	int countA=0,countB=0;

	int Ahan[100],Ahua[100],Bhan[101],Bhua[100];

	scanf("%d%d",&A,&B);

	scanf("%d",&N);

	for(i=0; i<N; i++)scanf("%d%d%d%d",&Ahan[i],&Ahua[i],&Bhan[i],&Bhua[i]);

	for(i=0; i<N; i++){if((Ahua[i]==(Ahan[i]+Bhan[i]))&&(Bhua[i]==(Bhan[i]+Bhan[i])))

				continue;

		if(Ahua[i]==(Ahan[i]+Bhan[i])){

			countA++;				// The number of cups increases by 1

			A--;					// Drink less alcohol

			if(A<0) {printf("A\n%d\n",countB);		//count does not print that

				break; }}else
 
			if(Bhua[i]==(Ahan[i]+Bhan[i])){

				countB++;

				B--;

				if(B<0) {printf("B\n%d\n",countA);

					break; }}}return 0;

}
Copy the code

16. Too handsome to have any friends (20 points)

L1-020 Too Handsome to Have Any Friends (20 marks) While most people are busy Posting photos on moments, there are always some people who are too handsome to have any friends. Find the people who are too handsome to have any friends.

Input format: The first line of input gives a positive integer N (≤100), which is the number of known friend circles. Each line is given a positive integer K (≤1000) for the number of people in the circle of friends, and then lists all the people in a circle of friends. For convenience, each person has an ID number of 5 digits (00000 to 99999), separated by Spaces. A positive integer M (≤10000) is the number of people to be queried. The following line lists the M ids to be queried, separated by Spaces.

Note: people without friends can be those who have not installed “moments” at all, or those who have only one person in moments. Although there are a few narcissists who repeatedly add themselves to their circle of friends, they guarantee that all groups with a K greater than 1 have at least two different people in their circle of friends.

Output format: Output those who are too handsome to have any friends in the order of input. Ids are separated by one space. There must be no extra space at the beginning or end of each line. If No one is handsome, the command output is “No one is handsome”.

Note: The same person can be queried more than once, but output only once.

Input Example 1: 33 11111 22222 55555 2 33333 44444 4 55555 66666 99999 77777 8 55555 44444 10000 88888 22222 11111 23333 88888 Example 1: 10000 88888 23333 Example 2:3 11111 22222 55555 2 33333 44444 4 55555 66666 99999 77777 4 55555 44444 22222 11111 Example 2: No one is handsome

#include <stdio.h>
#include <string.h>
int love[100010];		// Store the ID space
int main(a)
{
	int n;			// There are several circles of friends
	int k;			// There are several people in each circle of friends
	int m;			// Number of people to be queried
	int id;			/ / id number
	int newid;		// Id to be queried
	int i,j;		// For loops and array subscripts
	int flag=0;		// It is used to determine if the output result is too handsome to have friends
	scanf("%d",&n);
	    
        for(i=0; i<n; i++) {scanf("%d",&k);
            for(j=0; j<k; j++) {scanf("%d",&id);
                if(k == 1)break;// Only your own circle of friends
                love[id] = 1;   // Everyone's ID must be different, so let's set the value of all known friends to 1}}scanf("%d",&m);
        for(i=0; i<m; i++) {scanf("%d",&newid);
            if(! love[newid])// If the condition is not true or false, the non-false is true property, it already exists
            {               // There is no need for the output. To take advantage of this feature, we just need to put the output that does not exist in advance
                if(++flag > 1) printf("");
                printf("%05d",newid);
                love[newid] = 1; }}if(flag == 0) printf("No one is handsome");
        printf("\n");
    return 0;
}
Copy the code

17. Say important words three times (5 marks)

L1-021 Important Words Say three times (5 marks) No input for this super simple question.

All you have to do is say the very important words — “I’m gonna WIN!” Print it three times in a row.

Note that each row is on one line, and there should be no extra characters except carriage returns on each line.

Example: None Example: I’m gonna WIN! I ‘m gonna WIN! I ‘m gonna WIN!

#include <stdio.h>
void f(a)
{
	printf("I'm gonna WIN! \n");
}
int main(a)
{
	f();
	f();
	f();
	return 0;
}
Copy the code

18. Odd and Even split (10 points)

Given N positive integers, how many odd and even integers are there?

Input format: The first line of input gives a positive integer N (≤1000); Line 2 gives N non-negative integers, separated by Spaces.

Output format: Output the number of odd numbers and even numbers successively in a line. Separate the names with one space.

Example Value: 9 88 74 101 26 15 0 34 22 77 Example value: 3 6

#include <stdio.h>
int main(a)
{
	int N;				// How many numbers to enter
	int i;				// for loop
	int a[1000];		// The given maximum array space stores the input data in case the subscript is out of bounds
	int num1=0,num2=0;	// use it to calculate odd/even numbers
	scanf("%d",&N);
	if(N<=0 || N>1000) return 0;	// Natural numbers greater than 0 are positive integers
	for(i=0; i<N; i++)scanf("%d",&a[i]);
	for(i=0; i<N; i++) {if(a[i]%2! =0)
			num1++;
		else
			num2++;
	}
	printf("%d %d\n",num1,num2);
	return 0;
}
Copy the code

19. Output GPLT (20 points)

L1-023 Output GPLT (20 marks) Given a string of up to 10000 English letters. Please reorder the characters, press GPLTGPLT… This order is printed, ignoring other characters. Of course, the number of the four characters (case insensitive) is not necessarily the same. If a character has been printed, the remaining characters are printed in GPLT order until all characters have been printed.

Input format: A line containing a non-empty string of up to 10000 English letters.

Output format: Output the sorted string in a line as required by the topic. They make sure the output is not empty.

Input the sample: pcTclnGloRgLrtLhgljkLhGFauPewSKgt output sample: GPLTGPLTGLTGLGLL

#include<stdio.h>
#include<string.h>
int main(a)
{
	char str[10010];			// Memory space for storing input strings
	int g=0,p=0,l=0,t=0;		// These four variables are used to count the number of occurrences in the string
	int i,j;					// For loops and array subscripts
	int n;						// Get the length of the string entered
	gets(str);					// Provide input function
	n = strlen(str);			// Get the length of STR string and assign it to n
	for(i=0; i<n; i++)Start with the first letter and look for g, g, T, T, L, L,p, p
	{							// If there is one, the number of occurrences will be counted in the for loop, because each corresponding sequence will be +1
		if(str[i]=='g' || str[i]=='G')
			g++;
		else if(str[i]=='p' || str[i]=='P')
			p++;
		else if(str[i]=='l' || str[i]=='L')
			l++;
		else if(str[i]=='t' || str[i]=='T')
			t++;
	}
	while(n)					// For each letter that corresponds to the output, subtract 1
	{							// No need to print until they all return to the initial value of 0, then n=0, judged false end of the loop
		if(g! =0)
		{	printf("G");	g--;	}
		if(p! =0)
		{	printf("P");	p--;	}
		if(l! =0)
		{	printf("L");	l--;	}
		if(t! =0)
		{	printf("T");	t--;	}
		if(g==0 && p==0 && l==0 && t==0)
			n=0;
	}
	printf("\n");
	return 0;
}
Copy the code

20, The day after tomorrow (5 marks)

If today is Wednesday, the day after tomorrow is Friday. If today is Saturday, the day after tomorrow will be Monday. We use the numbers 1 through 7 for Monday through Sunday. Given a day, print the day after that day.

Input format: The first line gives a positive integer D (1 ≤ D ≤ 7), representing a certain day of the week.

Output format: Print the day of the week the day after D in one line.

Example Input: 3 Example output: 5

#include<stdio.h>
int main(a)
{
	int d;	/ / input
	scanf("%d",&d);
	if(d<1 || d>7)	return 0;
	if(d<=5)
		printf("%d",d+2);
	else
		printf("%d",d7 -+2);
	return 0;
}
Copy the code

It’s not easy to make. Please give me a thumbs up if you like. I’m Wang Rui.

It’s not easy to make. Please give me a thumbs up if you like. I’m Wang Rui.

21, A+B (15 分)

L1-025 positive integers A+B (15 marks) the objective of the problem is simply to find the sum of two positive integers A and B, where A and B are in the interval [1,1000]. Slightly troublesome, the input is not guaranteed to be two positive integers.

Input format: Input gives A and B on one line, separated by Spaces. The problem is that A and B don’t have to be positive integers. Sometimes they can be numbers out of range, negative numbers, real numbers with A decimal point, or even A bunch of garbled code.

Note: We consider the first space in the input to be the separation of A and B. They make sure there is at least one space and that B is not an empty string.

Output format: If the input is indeed two positive integers, the output is in the format A + B = and. If an input is not desirable, output at the appropriate location? And obviously the sum is also right? .

Input Example 1:123 456 Output Example 1:123 + 456 = 579 Input example 2:22. 18 Output Example 2:? + 18 =? Example 3: -100 blabla bla… 33 Example 3:? +? =?

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	static String a,b;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		a = scan.next();
		b = scan.next();
		boolean a1 = isNumeric(a);
		boolean a2 = isNumeric(b);
		if(a1&&a2) {			// If both numbers are numbers
		int number1 = Integer.valueOf(a);
		int number2 = Integer.valueOf(b);
		System.out.println(number1 + "+" + number2 + "=" + (number1+number2));
		}
		else if(a1==true&&a2==false) {//a is a number b is not
			int number1 = Integer.valueOf(a);
			System.out.println(number1 + "+" + "?" + "=" + "?");
		}else if(a1==false&&a2==true) {		//b is a number a is not
			int number1 = Integer.valueOf(b);
			System.out.println("?" + "+" + number1 + "=" + "?");
		}else {								/ / is not
			System.out.println("?" + "+" + "?" + "=" + "?"); }}public static boolean isNumeric(String str ){		// Check if it is a number
         Pattern pattern = Pattern.compile("[0-9] *");
         Matcher isNum = pattern.matcher(str);
         if( !isNum.matches() ){
             return false;
         }
         return true; }}Copy the code

22, I Love GPLT (5 分)

L1-026 I Love GPLT (5 marks) No input for this super simple question.

All you have to do is print this very important sentence — “I Love GPLT” — vertically.

The so-called “vertical output” means that each character occupies one line (including Spaces), that is, each line can have only one character and carriage return.

Example Input: None Example output: I

L

o

v

e

G P L T Note: There is a space in each of the two blank lines in the output.

#include<stdio.h>
#include<string.h>
int main(a)
{
	char a[]="I Love GPLT";
	int m=strlen(a);
	for(int i=0; i<m; i++)printf("%c\n",a[i]);
}
Copy the code

23. Rent (20 points)

L1-027 Rental (20 points) Here’s a picture that used to go viral on Sina Weibo:

For a time online a cry for help, urgent ask this how to break. Index [0]=2 arR [2]=1, index[1]=0 arR [0]=8, index[2]=3 arR [3]=0, and so on… It’s easy to get the phone number 18013820100.

This requires you to write a program that generates this code for any phone number — in fact, just the first two lines.

Input format: Input gives an 11-digit mobile phone number in one line.

Output format: Generate the first two lines of code for the input number, where the numbers in the ARR must be given in descending order.

Example: int[] arr = new int[]{8,3,2,1,0}; Int [] index = new int[]{3,0,4,3,1,0,2,4,3,4,4};

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> alist = new ArrayList<Integer>();
		String s = sc.nextLine();// Get the phone number
		// Store the phone number in the alist array
		for (int i = 0; i < s.length(); i++) {
			if(! alist.contains(Integer.valueOf(s.charAt(i) +""))) {
				alist.add(Integer.valueOf(s.charAt(i) + "")); }}// Sort (from smallest to largest)
		Collections.sort(alist);
		/ / reverse
		Collections.reverse(alist);
		System.out.print("int[] arr = new int[]{");
		/ / output
		for (int i = 0; i < alist.size(); i++) {
			if (i == 0) {
				System.out.print(alist.get(i));
			} else {
				System.out.print("," + alist.get(i));
			}
		}
		System.out.println("};);
		System.out.print("int[] index = new int[]{");
		
		// Outputs the subscript of the phone number sequence
		for (int i = 0; i < s.length(); i++) {
			if (i == 0) {
				System.out.print(alist.indexOf(Integer.valueOf(s.charAt(i) + "")));
			} else {
				System.out.print("," + alist.indexOf(Integer.valueOf(s.charAt(i) + "")));
			}
		}
		System.out.println("};); }}Copy the code

24. Are you too fat (5 points)

Is l1-029 too fat (5 points) It is said that the standard weight for a person is the weight in kilograms obtained by subtracting 100 from his height in centimetres and multiplying by 0.9. We know that a kilo is twice as much as a kilo. Now given someone’s height, please calculate the standard weight should be what? (Do the math for yourself, by the way…)

Input format: The first line of input gives a positive integer H (100 < H ≤ 300) for someone’s height.

Output format: Output the corresponding standard weight in one line, the unit is jin, with 1 decimal place reserved.

Input example: 169 Output example: 124.2

#include <stdio.h>
int main(a)
{
	float H;		// Enter a positive integer to indicate someone's height
	scanf("%f",&H);
	if(H<=100 || H>300)		return 0;
	According to the formula :(kg) standard weight = height -100*0.9
	//1 kg =2 kg
	printf("%.1f\n",((H- 100.) *0.9) *2);		// The result is a decimal number
	return 0;
}
Copy the code

25. A gang of one (15 points)

L1-030 a group (15 marks) A group study group is a common learning organization in primary and secondary schools, where teachers put the top students in groups with the bottom students. In this case, please write a program to help the teacher to automatically complete the assignment, that is, after getting the rank of the class students, in the current group of students, the most ranked students and the most ranked students of the opposite sex into a group.

Input format: The first line of input gives a positive even number N (≤50), which is the number of students in the class. After that, N lines are given each student’s gender (0 for girl, 1 for boy) and name (a non-empty string of up to eight English letters) in descending order, separated by one space. The ratio of boys to girls in this class is 1:1, and there is no joint ranking.

Output format: Each line outputs a group of two students’ names separated by one space. The students with higher ranking are in front and the students with lower ranking are behind. The group outputs are ranked in descending order of the previous students.

Example: 8 0 Amy 1 Tom 1 Bill 0 Cindy 0 Maya 1 John 1 Jack 0 Linda Example: Amy Jack Tom Linda Bill Maya Cindy John

#include<stdio.h>
int main(a)
{
	int N;				// Indicates the total size of the class
	int sex[50];		/ / gender
	char name[50] [15];	/ / name
	int i,j,k;			// for loop
	scanf("%d",&N);
	if(N<=0 || N>50 ||N%2! =0)	return 0;	// An even number, between 1 and 50
	for(i=0; i<N; i++)scanf("%d %s",&sex[i],&name[i][0]);
	for(i=0; i<N/2; i++)// Control the number of rows, since there are 8 people, so maximum 4 rows
	{
		for(j=i; j==i; j++)// Control searches from the highest ranking down to the highest ranking
		{
			for(k=N- 1; k>=N/2; k--)// Control the search from low to high, because there are 8 people, so the bottom 4 correspond to the top 4, only 4 times
			{
				if(sex[j]! =sex[k]&&sex[j]<=1&&sex[k]<=1)
				{
					sex[j]=10;		// Because the boys are 1 and the girls are 0, we can exclude the selected ones by using the logic judgment above
					sex[k]=10;		// Because the boys are 1 and the girls are 0, we can exclude the selected ones by using the logic judgment above
					printf("%s %s\n",name[i],name[k]);
					break;
				}
			}
		}
	}
}
Copy the code

26. Are you too fat? (10 points)

Is l1-031 too fat (10 points) It is said that the standard weight for a person is the weight in kilograms obtained by subtracting 100 from their height in centimetres and multiplying by 0.9. Real weight and standard weight error within 10% are perfect shape (that is, the real weight – standard weight | | < standard weight (10%). We know that a kilo is twice as much as a kilo. Given a group of people’s height and actual weight, please tell them whether they are too fat or too thin.

Input format: The first line of input gives a positive integer N (≤ 20). Then N lines, each of which gives two integers, are a person’s height H (120 < H < 200; Unit: cm) and true weight W (50 < W ≤ 300; Unit: city jin), which is separated by a space.

Output format: output a conclusion for each person: if it is perfect figure, output You are Wan Mei! ; If You are too fat, output You are tai Pang le! ; Otherwise output You are tai shou le! .

Example: 3 169 136 150 81 178 155 Example: You are wan MEI! You are tai shou le! You are tai pang le!

#include<stdio.h>
#include<math.h>
int main(a)
{
	int n;				// There are several people
	float height;		/ / height
	float weight;		// True weight
	float biao;			// Standard weight
	int i;				// For loops and array subscripts
	scanf("%d",&n);
	for(i=0; i<n; i++) {scanf("%f %f",&height,&weight);
		biao = (height- 100.) *0.9*2;	// Get the standard weight in kg
		if(fabs(weight-biao)<biao*0.1)
			printf("You are wan mei! \n");
		else if(biao>weight)
			printf("You are tai shou le! \n");
		else
			printf("You are tai pang le! \n");
	}
	return 0;
}
Copy the code

27, Left pad (20 points)

According to the news on Sina Weibo, there was a developer who was dissatisfied with NPM (Node Package Manager) and withdrew his open source code, including a module called left-pad, This is the module that crashed javascript React/Babel. What kind of module is this? It’s just padding something in front of the string to a certain length. For example, if you populate the string GPLT with a length of 10, the result of the left-pad call should be *****GPLT. The Node community has had an emergency release of an alternative to left-pad, which has been heavily mocked. Now you will implement this module.

Input format: The first line of input gives a positive integer N (≤10 4) and a character, separated by a space, which is the length of the resulting string and the character used for filling. The second line gives the original non-empty string, ending with carriage return.

Output format: Output the result string in one line.

Example 1:15 _I love GPLT Example 1: ____I love GPLT Example 2:4 * This is a sample for cut Example 2: CUT

#include<stdio.h>
#include<string.h>
int main(a)
{
	int  i;				// For loops and array subscripts
	int  n;				// Fill in the length of the string
	char c;				// Fill the string with characters
	char a[60000];		// Apply for string input space
	int lenght;			// The length of the string
	scanf("%d %c",&n,&c);
	getchar();
	gets(a);
	lenght=strlen(a);	// Calculates the length of the string
	if(lenght<n)		// When the input string < fills the string length
	{
		for(i=0; i<n-lenght; i++)printf("%c",c);
		puts(a);
	}
	else				/ / otherwise
	{
		for(i=lenght-n; i<lenght; i++)printf("%c",a[i]);
	}
	return 0;
}
Copy the code

28. Year of Birth (15 points)

L1-033 Year of Birth (15 points)

“I was born in 1988 and didn’t meet four different years until I was 25 years old,” read one of the bizarre posts on Sina Weibo. In other words, the requirement that all four numbers are different was not met until 2013. I was born in year Y and didn’t meet n years with different numbers until I was x.

Input format: Enter the number of different numbers n in the birth year Y and the target year in a line, where y is between [1, 3000] and n can be 2, or 3, or 4. Note that years with less than four digits are preceded by zeros. For example, AD 1 is considered year 0001 and has two different digits, 0 and 1.

Output format: according to the input, output X and can meet the requirements of the year. Digits are separated by one space. There must be no extra space at the beginning and end of each line. The year should be printed in 4 digits. Note: “n numbers are not the same” means that different numbers are exactly N. For example, “2013” is considered to satisfy the condition of “all four digits are different”, but not the condition of two or three digits being different.

Example 1:1988 4 Example 1:25 Example 2013 Example 2:1 2 Example 2:0 0001

#include<stdio.h>
#include<string.h>
int main(a){
	int cnt=0,same=0;
	int a[10];
	//memset(a,0,sizeof(a));
	int year,t,d;
	int i;
	scanf("%d%d",&year,&d);
	t=year;
	while(1) {memset(a,0.sizeof(a));
		for(i=0; i<4; i++){ a[t%10] = 1;
			t/=10;
		}
		same=0;
		for(i=0; i<10; i++) same+=a[i];if(same==d) break;
		cnt++;
		year++;
		t=year;
	}
	printf("%d %04d",cnt,year);
	return 0;
}
Copy the code

29. Thumbs up (20 points)

L1-034 Likes (20 points) There is a “like” function on Weibo where you can show your support by giving a “like” to a blog post you like. Every blog post has tags that define its identity, and the type of blog you like indirectly defines your identity. Write a program that analyzes a person’s characteristics by counting their likes.

Input format: Input in the first line gives a positive integer N (≤1000), which is the number of blog posts that the user likes. In the following N lines, each line gives a feature description of a blog that has been liked by the blog in the format of “K F 1… F K”, where 1≤K≤10, and F I (I =1…,K) is the number of feature labels. We number all feature labels from 1 to 1000. Numbers are separated by Spaces.

Output format: count the feature tag that most frequently appears in all the liked blog posts, output its number and occurrence times in a line, with 1 space between the numbers. If there is a tie, the one with the largest number is printed.

Example: 4 3 889 233 2 5 100 3 233 2 73 4 3 73 889 2 2 233 123 Example: 233 3

#include<stdio.h>
#define N 1001
int main(a)
{	
	int n;					// The number of likes
	int i,j;				// For loops and array subscripts
	int k;					// Indicates that several attribute tags are required
	int app[N]={0};			// Store label number
	int id;					/ / id number
	int index1=0;			// The maximum number of occurrences of the tag
	int index2=0;			// mark the maximum number of occurrences
	scanf("%d",&n);
	for(i=0; i<n; i++) {scanf("%d",&k);
		for(j=0; j<k; j++) {scanf("%d",&id);
			app[id]++;		// This is equivalent to a[3]++ for every value entered,
							// Increment by 1 for that coordinate}}for(i=0; i<N; i++)// Check from the smallest number according to the for loop
	{
		if(app[i]>=index1)	// If a[I] contains a value greater than the maximum number of times previously marked,
		{					// Then index1 should mark the number of occurrences
			index1=app[i];	// Because the loop is from small to large, so if there is exactly equal and ID
			index2=i;		If the number is still larger than before, the if statement is also executed
		}					// This avoids the problem of comparing number sizes in the same number of times
	}
	printf("%d %d\n",index2,index1);
	return 0;
}
Copy the code

30. Valentine’s Day (15 points)

L1-035 Valentine’s Day (15 points)

“February 14th, Valentine’s Day, I decided to benefit everyone. For the 2nd and 14th thumbs up, I introduce you to ………… We three have dinner… Both of you please…” . Here is a list of the friends who like this post, please find out the two unlucky people who want to treat.

Input format: Enter the name of a person with unknown number of likes in the order of likes. Each name is a non-empty word with no more than 10 English letters on a line, and the name is ended with a carriage return. An English period. Marks the end of input. This symbol is not included in the “like” list.

A and B are inviting you to dinner… A and B are inviting you to dinner… ; If there is only A without B, A is the only one for you… ; If there is no A, output “Momo… No one is for you…” .

Input Example 1: GaoXZh Magi Einst Quark LaoLao FatMouse ZhaShen fantacy latesum SenSen QuanQuan whatever whenever Potaty hahaha . Example 1: Magi and Potaty are inviting you to dinner… Example 2: LaoLao FatMouse whoever. Example 2: FatMouse is the only one for you… Example 3: LaoLao. Example 3: Momo… No one is for you…

#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(a)
{
	char str1[10010] [11];	// Save space for strings
	int i;					// For loops and array subscripts
	int n=0;				// Decide to output the result, according to the list of friends into three cases
	int t;			
	for(i=0; i<1000; i++) { gets(str1[i]);if(strcmp(str1[i],".") = =0)	/ / "." Represents the end of input, using a string comparison function
		{	t=i;break;	}
		n++;				// Each time you have a friend, n increases by itself, using n as the output standard
	}
	if(n>=14)
		printf("%s and %s are inviting you to dinner... \n",str1[1],str1[13]);
	else if(n<2)
		printf("Momo... No one is for you ... \n");
	else if(n<14 && n>=2)
		printf("%s is the only one for you... \n",str1[1]);
	return 0;
}
Copy the code

31, A times B (5 marks)

L1-036 A times B (5 marks) Here’s A problem you can solve in less than 10 seconds: Given two integers A and B with absolute values of 100 or less, print the value of A times B.

Input format: The first line contains two integers A and B (−100≤A,B≤100), separated by Spaces.

Output format: Print the value of A times B in one line.

Example Value: -8 13 Example value: -104

#include<stdio.h>
int main(a)
{
	int A,B;
	scanf("%d %d",&A,&B);
	if(A<- 100. || A>100 || B<- 100. || B>100)	return 0;
	printf("%d\n",A*B);
	return 0;
}
Copy the code

32, A divided by B (10 marks)

Given two integers A and B with absolute values of 100 or less, you are asked to print the result as A/B= quotient.

Input format: The first line contains two integers A and B (−100≤A,B≤100), separated by Spaces.

Output format: Output the result in one line: if the denominator is positive, output “A/B= quotient”; If the denominator is negative, use parentheses to output the denominator; If the denominator is zero, the quotient of the output should be Error. The quotient of output should be reserved to 2 decimal places.

Example Input 1: -1 2 Example output 1: -1/2=-0.50 Example input 2:1-3 Example output 2:1/(-3)=-0.33 Example input 3:50 0 Example output 3:5/0=Error

#include<stdio.h>
int main(a)
{
    int a,b;
	float s;
    scanf("%d%d",&a,&b);
    s=1.0*a/b;			// The best way to compute a decimal like this is by using the
    if(b>0)				//*0.1 to keep two decimal places, because this does not affect the value
        printf("%d/%d=%.2f",a,b,s);	// If both are initially set to double, the rounding may not be handled properly when reserved
    if(b==0)
        printf("%d/%d=Error",a,b);
    if(b<0)
        printf("%d/(%d)=%.2f",a,b,s);
    return 0;
}
Copy the code

33. New World (5 points)

L1-038 New World (5 marks) No input for this super easy question.

All you need to do is print the programmer’s king James phrase “Hello World” on the first line and the updated “Hello New World” on the second line.

Example value: Hello World Hello New World

#include<stdio.h>
int main(a)
{
	printf("Hello World\n");
	printf("Hello New World\n");
	return 0;
}
Copy the code

34. Ancient Style layout (20 points)

L1-039 Ancient style typesetting (20 points) Chinese ancient people wrote characters in vertical typesetting from right to left. Please write a program to type a paragraph of text according to the ancient style.

Input format: Input gives a positive integer N (<100) on the first line, which is the number of characters in each column. The second line gives a non-empty string of up to 1000 length, ending with a carriage return.

Output format: Type the given string in archaic format, N characters per column (except perhaps less than N for the last column).

4 This is a test case Asa T st Ih e TSI CE s

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
	int i,j,n;
	scanf("%d",&n);
	char s[10010];
	getchar();
	gets(s);
	int t = strlen(s);
	int k = t/n;
	if(t%n! =0)
	k++; 
	for(i=0; i<n; i++) {for(j=n*k-n+i; j>=0; j=j-n) {printf("%c",s[j]);
		}
		printf("\n");
	}
	return 0;
}
Copy the code

35. Best Height difference between couples (10 points)

Using data from multiple couples, experts found that the optimal height difference between couples follows a formula :(the woman’s height) ×1.09 = (the man’s height). If so, the height difference between the two of you, whether holding hands, hugging, or kissing, is the most harmonious difference.

Here you write a program, for any user to calculate the best height of his/her lovers.

Input format: The first line is a positive integer N (≤10), indicating the number of users to be queried. Then N lines, each line gives the gender and height of the user to query according to the format of “gender height”, where “gender” is “F” for female, “M” for male; “Height” is a real number between [1.0, 3.0].

Output format: For each query, calculate the best height of the couple for the user in one line, reserving 2 decimal places.

Example Input: 2 M 1.75F 1.8 Example output: 1.61 1.96

#include<stdio.h>
int main(a)
{
	int N;				
	char sex[10];		
	float	height[10];	
	int i;			
	scanf("%d",&N);
	if(N<1 || N>10)	return 0;
	for(i=0; i<N; i++)scanf("%s%f",&sex[i],&height[i]);
	for(i=0; i<N; i++) {if(sex[i] == 'M')
			printf("%.2f\n",height[i]/1.09);
		else
			printf("%.2f\n",height[i]*1.09);
	}
		return 0;
}
Copy the code

36. Looking for 250 (10 points)

L1-041 Looking for 250 (10 points)



They don’t want to talk to you and throw a bunch of numbers at you… And you have to find the lofty and touching number “250” in the list.

Input format: The input gives an unknown number of integers with absolute values less than 1000 in a row. At least one “250” is guaranteed.

Output format: Output the first occurrence of “250” in a line is the number of the opponent threw (counting from 1). They make sure the output number is in the integer range.

Example Input: 888 666 123-233 250 13 250-222 Example output: 5

#include<stdio.h>
int main(a)
{
	int i;			
	int a[10000];	
	for(i=0; i<10000; i++) {scanf("%d",&a[i]);
		if(a[i]==250)
		{
			printf("%d\n",i+1);
			break; }}return 0;
}
Copy the code

37. Date formatting (5 marks)

L1-042 Date formatting (5 marks) Different countries in the world have different dates. For example, Americans tend to write “month-day-year”, while Chinese people tend to write “year-month-day”. Please write a program below, automatically read in the United States format of the date to rewrite the Chinese custom date.

Input format: Enter the month, day, and year in the MM-DD-YYYY format. They guarantee that the dates given are legal from New Year’s Day 1900 to the present.

Output format: The year, month, and day are displayed in the format YYYY-MM-DD.

Example: 03-15-2017 Example: 2017-03-15

#include<stdio.h>
int main(a)
{
	int month;	
	int day;	
	int year;	
	scanf("%d-%d-%d",&month,&day,&year);
	if(year>=1900)
	printf("%d-%02d-%02d\n",year,month,day);
	return 0;
}
Copy the code

Reading Room (20 points)

L1-043 Reading Room (20 points) Sky Ladder Reading Room Please write a simple loan statistics program. When the reader borrows a book, the administrator enters the ISbn and presses the S key, and the program starts timing; When the reader returns the book, the administrator enters the ISbn and presses the E key, and the program ends. The isbn must be a positive integer up to 1000. When the administrator enters 0 as an ISbn to indicate the end of the day, your program should output the number of times readers borrowed books and the average reading time for that day.

Note: Due to occasional line failures, incomplete records may occur, i.e. only S without E, or only E without S. The system should automatically ignore such invalid records. In addition, they ensure that an ISbn is unique to a book and that only one reader can borrow a book at any one time.

Input format: Input is given a positive integer N (≤10) on the first line, followed by N days. The daily record consists of a number of borrowing operations, each operation occupies a line, in the format of:

Isbn (integer within [1, 1000]) key value (S or E) occurrence time (hh:mm, where hh is an integer within [0,23] and mm is an integer within [0, 59])

The records for each day are guaranteed to be presented in ascending chronological order.

Output format: For daily records, output in one line the number of times readers borrowed books and the average reading time (integer time in minutes to the one digit) for that day.

Example Input: 3 1 S 08:10 2 S 08:35 1 E 10:00 2 E 13:16 0 S 17:00 0 S 17:00 3 E 08:10 1 S 08:20 2 S 09:00 1 E 09:20 0 E 17:00 2, 196, 0, 0, 1, 60

#include <stdio.h>

int main(a)
{
    int N;
    scanf("%d", &N);

    while (N--) {
        int id;
        int books[1001] [2] = {0};
        char key;
        int hh, mm; 

        while (scanf("%d %c %d:%d", &id, &key, &hh, &mm) && id) {

            // If you want to borrow
            if (key == 'S') {
                books[id][0] = - 1;              // Set the borrow flag
                books[id][1] = hh * 60 + mm;    // Count the time in minutes
            } else if (books[id][0] = =- 1) {
                // Return the book, and the previous record of borrowing

                // The total number of books borrowed increases by 1
                books[0] [0] + +;// Calculate the borrowing time
                int total = hh * 60 + mm - books[id][1];

                // Add total borrowing time
                books[0] [1] += total;       

                // Restore the loan mark of the book to allow borrowing next time
                books[id][0] + +; }// if-else

        } // while id ! = 0

        int ave_m = 0;
        if (books[0] [0] > 0) {
            double m = books[0] [1] * 1.0 / books[0] [0];
            // Round to the bottom
            ave_m = (int)(m + 0.5);
        }

        printf("%d %d\n", books[0] [0], ave_m);

    } // while (N-- > 0)

    return 0;
 }
Copy the code

39. Sure win (15 points)

L1-044 Secure Win (15 points) You should be able to play “paper, hammer, scissors” : two people give hand signals at the same time, and the rules are shown below:

Now ask you to write a steady win not lose the program, according to the other party’s move, give the corresponding win. But! To keep your opponent from losing too badly, you need to draw every K times.

Input format: Input begins with a positive integer K (≤10), the number of draw intervals, on the first line. Then each line gives the opponent a move: ChuiZi for hammer, JianDao for scissors, Bu for paper. End indicates the End of input. This line should not be treated as a move.

Output format: for each input move, according to the requirements of the output win or draw move. Each move takes one line.

Example: 2 ChuiZi JianDao Bu JianDao Bu ChuiZi ChuiZi End Example: Bu ChuiZi Bu ChuiZi JianDao ChuiZi Bu

#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(a)
{
	int i;			// for loop
	int k;			// Indicates the number of intervals between draws
	int index;		// mark the number of draws
	char name[20];	// Enter the name of the offer
	scanf("%d",&k);
	index=k;		// mark the interval times
	while(1)
	{
		scanf("%s",name);
		if(strcmp(name,"End") = =0)
			break;
		else
		{
			if(index==0)
			{
				if(strcmp(name,"ChuiZi") = =0)
					printf("ChuiZi\n");
				if(strcmp(name,"JianDao") = =0)
					printf("JianDao\n");
				if(strcmp(name,"Bu") = =0)
					printf("Bu\n");
				index = k;
			}
			else
			{
				if(strcmp(name,"ChuiZi") = =0)
					printf("Bu\n");
				if(strcmp(name,"JianDao") = =0)
					printf("ChuiZi\n");
				if(strcmp(name,"Bu") = =0)
					printf("JianDao\n");
				index--;			// Each time you win, the interval is 1 less. When =0, draw}}}return 0;
}
Copy the code

40, the universe is invincible hello (5 points)

It is said that the first program any programmer learns is to say Hello to the World by printing “Hello World” on the screen. As a programmer in a ladder game, you need to write advanced programs that can greet any given planet.

Input format: Enter the name of a planet S on the first line, a word with no more than seven letters, ending with a carriage return.

Output format: Output Hello S in one line to say Hello to the input planet S.

Example: Mars Example: Hello Mars

#include<stdio.h>
int main(void)
{
	char s[8];
	gets(s);
	printf("Hello ");
	puts(s);
}
Copy the code

It’s not easy to make. Please give me a thumbs up if you like. I’m Wang Rui.

It’s not easy to make. Please give me a thumbs up if you like. I’m Wang Rui.

41. Single (20 points)

L1-046 Single (20 points) The so-called “bachelor” here, I don’t mean single, I mean all the numbers made up of ones, such as 1, 11, 111, 1111, etc. Legend has it that any single person can be divisible by an odd number that does not end in 5. For example, 111111 is divisible by 13. Now, your program reads an integer x, which must be odd and does not end in 5. Then, after calculation, two numbers are printed: the first number, S, indicates that x times S is a single, and the second number, N, is the number of digits of the single. Of course, there are not unique solutions, and they want you to output the smallest solution.

Tip: One obvious solution is to gradually increase the number of singles until x is divisible. The difficulty is that s can be a very large number — for example, if the program inputs 31, it outputs 3584229390681 and 15, because 31 times 3584229390681 yields 111111111111111, which is a total of 15 ones.

Input format: Input gives a positive odd number x (<1000) on a line that does not end in 5.

Output format: Print the corresponding minimum s and n on a single line, separated by 1 space.

Example: 31 Example: 3584229390681 15

#include<stdio.h>  
int main (a)
 {  
    int n, len=0,p=0,now=1;  
    char ans[1000];  
    scanf("%d",&n);  
    while (!0)
{  
   len++;                 / / 1,11,111,111... Try to see if it's divisible
        if(p||now/n)          P ==0; p==0; p==0
        ans[p++]='0'+now/n;   // convert to character
        now%=n;               // The remainder is the key to analog division
        if(now==0) 
{                   // The remainder is 0
            ans[p]='\ 0'; // String terminator is added to a string created by yourself step by step
            printf("%s %d\n", ans, len);  
            break;  
        }  
        now=now*10+1; // Multiply by 10 is the key to analog division
    }  
    return 0;  
}
Copy the code

42. Pretending to sleep (10 points)

L1-047 Faking sleep (10 points) You’ll never wake up a faking fool — but by analyzing a person’s breathing rate and pulse, you can find out who is faking sleep! The doctor tells us that the normal breathing rate during sleep is 15-20 beats per minute and the pulse rate is 50-70 beats per minute. Given the respiratory rates and pulses of a series of people below, identify those who are likely to be faking it, i.e., those with at least one indicator outside the normal range.

Input format: Input is given a positive integer N (≤10) on the first line. This is followed by N lines, each of which gives a person’s name (a string of only English letters and no more than three characters in length), respiration rate, and pulse rate (all positive integers up to 100).

Output format: check each person according to the input order, if at least one indicator is not in the normal range, output its name, each name in a line.

Example: 4 Amy 15 70 Tom 14 60 Joe 18 50 Zoe 21 71 Example: Tom Zoe

#include<stdio.h>
int main(void)
{
	int N;	// Enter a positive integer
	scanf("%d",&N);
	char name[8] [4];	// Name // Be sure to set one more digit here
	int huxi[8];		// Respiration rate
	int maibo[8];		/ / the pulse
	int i;				// For loops and array subscripts
	for(i=0; i<N; i++)// Provide input function
		scanf("%s%d%d",&name[i][0],&huxi[i],&maibo[i]);
	for(i=0; i<N; i++)if(huxi[i]<15 || huxi[i]>20 || maibo[i]<50 || maibo[i]>70)
			puts(name[i]);
}
Copy the code

43, MATRIX A times B (15 marks)

Given two matrices A and B, you are asked to compute their product matrix AB. Note that only matrices that match in size can be multiplied. That is, if A has R, A rows and C, A columns, and B has R, B rows and C, B columns, then the two matrices can only be multiplied if C, A and R, B are equal.

Input format: The input gives two matrices A and B. For each matrix, the number of rows R and the number of columns C are given in one row, followed by R rows, each row is given C integers, separated by one space, with no extra space at the beginning and end of the row. The input ensures that R and C of both matrices are positive and that the absolute values of all integers do not exceed 100.

Output format: If the sizes of the two input matrices match, the product matrix AB is output in the format of the input. Otherwise, Error: Ca! = Rb, where Ca is the number of columns of A and Rb is the number of rows of B.

Example 1:2 3 1 2 3 4 5 63 4 7 8 9 0-1-2 3-4 5 6 7 8 Example 1:24 20 22 24 16 53 58 63 28 Example 2: 3 2 38 26 43-5 0 17 3 2-11 57 99 68 81 72 Example 2: Error: 2! = 3

#include<stdio.h>
#define N 100
#define M 100
int main(a)
{
	int a[N][M]={0},b[N][M]={0},c[N][M]={0};
	int i,j,k;				// For loops and array subscripts
	int ra,ca,rb,cb,rc,cc;	Row and column of rectangle A, row and column of rectangle B, and row and column of rectangle C
	int n;					//
	scanf("%d %d",&ra,&ca);
	for(i=0; i<ra; i++)/ / rectangle A
		for(j=0; j<ca; j++)scanf("%d",&a[i][j]);
	scanf("%d %d",&rb,&cb);

	for(i=0; i<rb; i++)B / / rectangle
		for(j=0; j<cb; j++)scanf("%d",&b[i][j]);
	if(ca == rb)
	{	// Notice that since we are multiplying two rectangles, we can be sure that these two rectangles are different looking,
		// When the same condition is determined by us, the other two conditions will determine the row and column criteria of rectangle C, so
		// Here we should combine the rows of rectangle A and the columns of rectangle B as the shape of rectangle C to participate in the calculation

		rc = ra;	// The rows of rectangle A are the rows of rectangle C
		cc = cb;	// The columns of rectangle B are used as columns of rectangle C
		n = ca;		// Here is the factor that determines the k cycle
		printf("%d %d\n",rc,cc);
		for(i=0; i<rc; i++)// Control the number of rows
		{
			for(j=0; j<cc; j++)// Control column number
			{
				for(k=0; k<n; k++)// Multiply the elements in the first row of rectangle A by the elements in the first column of rectangle B
				{					// And so on
					c[i][j]+=a[i][k]*b[k][j];
				}
				if(j! =cc- 1)
					printf("%d ",c[i][j]);
				else
					printf("%d",c[i][j]);
			}
			printf("\n");			// After each column of rectangle C is printed, the line is wrapped}}else	// Output this message when the data matches exactly
		printf("Error: %d ! = %d\n",ca,rb);
	return 0;
}
Copy the code

44, the NTH string (15 points)

L1-050 Penultimate NTH string (15 minutes) Given an arithmetic increasing sequence of strings consisting entirely of lowercase English letters, each string in the sequence has a fixed length of L, starting with L as and increasing by 1 step. For example, when L is 3, the sequence is {aaa, aab, aac… , AAZ, ABA, ABB… Abz,… , z}. The 27th string from the end of the sequence is zyz. For any given L, they’re asking you to give them the NTH to the last string from the corresponding sequence.

Input format: Input gives two positive integers L (2 ≤ L ≤ 6) and N (≤10 5) in a single line.

Output format: Output the NTH penultimate string of the corresponding sequence in one line. They guarantee that this string exists.

Input example: 3 7417 Output example: PAT

#include<stdio.h>
#include<math.h>
#define L 6

int main(a)
{
	char ch[26] = {'z'.'y'.'x'.'w'.'v'.'u'.'t'.'s'.'r'.'q'.'p'.'o'.'n'.'m'
	             ,'l'.'k'.'j'.'i'.'h'.'g'.'f'.'e'.'d'.'c'.'b'.'a'};
	char arr[L];
	int n,l,a,i;         //l is the length of the sequence, n is the position of the sequence in reverse order, and a is the position of a character of the desired string in the ch array
	scanf("%d %d",&l,&n);
	n=n- 1;               // The last character is correct after subtracting 1
	for(i=0; i<l; i++) { a=n/pow(26,l-i- 1);
		arr[i]=ch[a];
		n=n-a*pow(26,l-i- 1);
	}
	for(i=0; i<l; i++) {printf("%c",arr[i]);
	}
	return 0;
 }
Copy the code

45. Discount (5 points)

L1-051 Discount (5 cents) When you go to the mall to find a sale, calculating the price after the sale can be quite a mental exercise. For example, if the original price is ¥988 and marked 30% off, the discount price should be ¥988 x 70% = ¥691.60. Write a program to calculate the discount price for the customer.

Input format: Input the original price (positive integer not more than 10,000 yuan) and discount (integer within [1, 9]) of the product in one line, separated by Spaces.

Output format: Output the discount price of the product in one line, with 2 decimal places reserved.

Example Value: 988 7 Example value: 691.60

#include<stdio.h>
int main(void)
{
	double before_money;			/ / the original price
	double after_money;			/ / after the discount
	double zhe;					/ / discount
	scanf("%lf %lf",&before_money,&zhe);
	after_money=before_money*zhe/10;
	printf("%.2lf\n",after_money);
}
Copy the code

46. 2018 We need to win (5 points)

L1-052 2018 We Want to Win (5 points) The registration invitation code for the 2018 Ladder is “2018wmyy”, which means “2018 we want to win”. In this case, please use Chinese pinyin output this sentence.

Input format: No input in this topic.

Output format: Output “2018” in the first line. Second line: “wo3 men2 yao4 ying2!” .

Example: 2018 WO3 men2 yao4 ying2!

#include<stdio.h>
int main(void)
{
	printf("2018\n");
	printf("wo3 men2 yao4 ying2 ! \n");
	return 0;
}
Copy the code

47. Electron Wang (10 points)

Dogs are said to have the IQ of a four-year-old human child and are even more intelligent when it comes to adding numbers. For example, if you put two piles of balls on the ground, with one ball and two balls respectively, the clever wang will use “Wang! Wang! Woof!” That means 1 plus 2 is 3.

This requires you to create a simulation program for the tamagotchi, calculate the sum based on the number of two piles of balls recognized by the electronic eye, and give the answer using the bark of the dog.

Input format: Input gives two positive integers A and B in the [1, 9] range on A line, separated by Spaces.

Output format: output A + B Wang! .

Example Value: 2 1 Example value: Wang! Wang! Wan

#include<stdio.h>
int main(void)
{
	int A;	
	int B;
	scanf("%d %d",&A,&B);
	for(int i=1; i<=A+B; i++)printf("Wang!");
	return 0;
}
Copy the code

48. Who is the winner (10 points)

L1-055 Who is the winner (10 points) In an entertainment program of a TV station, two artists are arranged to perform each time. The winner is decided by the votes of the audience and the votes of three judges. The rules are: if an artist has the highest number of votes from the audience and is recognized by at least one judge, the artist wins; Or an artist with a low number of audience votes, but the recognition of all judges, can also win. The show guarantees an odd number of viewers to vote, so there is no tie. Who is the winner?

Input format: The first line of input gives two positive integers Pa and Pb not exceeding 1000, which are the audience votes obtained by artist A and artist B respectively. They guarantee that these two numbers are not equal. The second line then gives the results of the three judges’ votes. The number 0 represents a vote for A, and the number 1 represents a vote for B, separated by a space.

Output format: Output the winner in the following format:

The winner is x: P1 + P2 where X is The letter for The winner, P1 is The number of votes The winner received from The audience, and P2 is The number of votes The winner received from The judges.

The winner is a: 327 + 1 In recognition of The software College of Anyang Normal University, Li Dong students improve The test data.

Unit: Zhejiang University Time limit: 400 ms Memory limit: 64 MB

#include<stdio.h>
int main(void)
{
	int Pa;			// A's number of votes
	int Pb;			// B's number of votes
	int num;		// Judges vote
	int a=0,b=0;	// Count the votes of judges A and B
	scanf("%d %d",&Pa,&Pb);
	for(int i=0; i<3; i++) {scanf("%d",&num);
			if(num==0)
				a++;
			else
				b++;
	}
	if(Pa>Pb&&a! =0)
		printf("The winner is a: %d + %d\n",Pa,a);
	else if(Pa<Pb&&b! =0)
		printf("The winner is b: %d + %d\n",Pb,b);
	else if(Pa<Pb&&a==3)
		printf("The winner is a: %d + %d\n",Pa,a);
	else if(Pa>Pb&&b==3)
		printf("The winner is b: %d + %d\n",Pb,b);
}
Copy the code

49. De-weighting linked lists (25 points)

Given a linked list L with integer key values, you need to delete all key values that have the same absolute value. So for every key K, only the first node whose absolute value is K is preserved. Meanwhile, all deleted nodes must be saved on another linked list. For example, given L is 21→-15→-15→-7→15, you need to output the de-duplicated list 21→-15→-7, and the deleted list -15→15.

Input format: Input on the first line gives the address of the first node of L and a positive integer N (≤10 5, the total number of nodes). The address of a node is a non-negative 5-bit integer, and the NULL address is represented by −1.

Then N lines, each describing a node in the following format:

The address key is the next node where the address is the address of that node, the key is an integer with absolute value up to 10 or 4, and the next node is the address of the next node.

Output format: output the de-duplicated list first, and then output the deleted list. Each node is in a row and output in the format of input.

Example: 00100 5 99999-7 87654 23854-15 00000 87654 15-1 00000-15 99999 00100 21 23854 Example: 00100 21 23854 23854-15 99999 99999-7-1 00000-15 87654 87654 15-1

#include <stdio.h>
#include <string.h>
#include <math.h>
#define N 10*10*10*10*10+1
struct Node
{
    int jian,xia;		//jian > xia > next node
}node[N];
int main(a)
{
	int l,n;		//l→ first address, n→ several addresses, input several rounds
    int first;		// The starting address of each round
	int i,j;		// For loops and array subscripts
	int tmp[10001] = {0};
	// With the loop split list, check if the subscript appears, if so, assign the value to the deleted list
	int one[N],two[N];
	// One → represents the deleted list, and two → represents the deleted list
	int o=0,t=0;
	int num;		//num gets the key value of each address
	scanf("%d%d",&l,&n);
        for(i=0; i<n; i++) {scanf("%d",&first);
            scanf("%d%d",&node[first].jian,&node[first].xia);
        }
        for(i=l; node[i].xia ! =- 1;)
        {
            int num=abs(node[i].jian);
            if(tmp[num]==0)
            {
                tmp[num]=1;
                one[o++]=i;		// Storage address
            }
            else
            {
                two[t++]=i;
            }
            i=node[i].xia;
        }
		num=abs(node[i].jian);// Take note of the last subscript
        if(tmp[num]==0) { one[o++]=i; }else{ two[t++]=i; }printf("%05d %d ",one[0],node[one[0]].jian);
            for(j=1; j<o; j++) {printf("%05d\n",one[j]);
                printf("%05d %d ",one[j],node[one[j]].jian);
            }
            printf("%d\n".- 1);
            if(t! =0)		// Do not delete the linked list
            {
                printf("%05d %d ",two[0],node[two[0]].jian);
                for(j=1; j<t; j++) {printf("%05d\n",two[j]);
                    printf("%05d %d ",two[j],node[two[j]].jian);
                }
                printf("%d\n".- 1);
            }
			return 0;
}
Copy the code

50. Hall of Fame and Vouchers (25 points)

L2-027 Hall of Fame and Voucher (25 points) For students studying “Data Structures” in a Chinese University MOOC (www.icourse163.org/), in order to receive a certificate of competency, they must achieve a total score of 60 or above, with additional benefits: Those whose total score is within the range of [G, 100] can get a PAT voucher of 50 yuan; In [60 G) interval, PAT can get 20 yuan voucher. The national examination and general, effective in a year. At the same time, teacher also K before the overall performance of students on the course “fame”. Please bear on the program, help the teacher to students list the hall of fame, and statistics of how many yuan face value total PAT vouchers.

Input format: The input gives three integers in the first line, which are N (a positive integer up to 10,000, representing the total number of students), G (an integer in the (60,100) range, representing the voucher grade demarcation line described in the topic), and K (a positive integer up to 100 and up to N, representing the lowest rank for hall of Fame entry). The next N lines give each student’s account number (a string of up to 15 characters without Spaces) and total score (an integer within the range [0, 100]), separated by Spaces. They make sure there are no duplicate accounts.

Output format: First print the total value of the ISSUED PAT voucher in one line. Then output the rank, account number and score of the students entering the Hall of Fame in non-ascending order according to the total score, separated by 1 space. It should be noted that: students with the same score enjoy parallel ranking. When ranking is parallel, the output will be in alphabetical order of the account.

Example Input: 10 80 5 [email protected] 78 [email protected] 87 [email protected] 65 [email protected] 96 [email protected] 39 [email protected] 87 [email protected] 80 [email protected] 88 [email protected] 80 [email protected] 70 Example output: 360 1 [email protected] 96 2 [email protected] 88 3 [email protected] 87 3 [email protected] 87 5 [email protected] 80 5 [email protected] 80

Hall of Fame and Vouchers (25 points)

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct stu{
int id;/ / place
char edu[25];/ / account
int score;/ / result
};
// Sort algorithm?
int cmp(const void * a,const void * b)
{ 
	struct stu aa = *(struct stu *)a;
	struct stu bb = *(struct stu *)b;
	if(aa.score == bb.score)
	return strcmp(aa.edu,bb.edu); // When the score is the same, we compare the account.
	else
	return aa.score > bb.score ? - 1 : 1;
	}
	int main(a)
	{
	int N,G,K;
	struct stu stud[10005].
	while(scanf("%d%d%d",&N,&G,&K) ! = EOF){int i;
	int ans = 0;
	
	for(i = 0 ; i < N ; i++){
	scanf("%s %d",stud[i].edu,&stud[i].score);
	if(stud[i].score >= 60 && stud[i].score < G){
	ans += 20;
	}
	if(stud[i].score >= G && stud[i].score <= 100){
	ans += 50; }}printf("%d\n",ans);// Export vouchers?
	
	qsort(stud,N,sizeof(stud[0]),cmp);
	int num = 1;
	stud[0].id = 1;
	
	for(i = 1 ; i < N ; i++) // The ranking is handled after the order is sorted.
	{
	num++;
	if(stud[i].score == stud[i- 1].score){
	stud[i].id = stud[i- 1].id;
	}else{ stud[i].id = num; }}for(i = 0 ; i < K ; i++)
	printf("%d %s %d\n",stud[i].id,stud[i].edu,stud[i].score);
	int k = K;
	while(stud[K- 1].score == stud[k].score){// There are no students ranked less than or equal to K after the output of K students.
	printf("%d %s %d\n",stud[k].id,stud[k].edu,stud[k].score); k++; }}return 0;
}
Copy the code

51. Make small change (30 cents)

Han Meimei likes to go shopping everywhere in the universe. Now she visits a Martian store and discovers that it has a special rule: you can pay with coins from any planet, but no change, and of course no debt. Han Meimei has 10 or 14 coins from all over the world at hand and needs you to help her calculate whether it is possible to come up with the exact amount to pay.

Input format: The first line of input gives two positive integers: N (≤10 4) is the total number of coins, and M (≤10 2) is the amount that Han Meimei should pay. The second line gives the positive integer face values of N coins. Numbers are separated by Spaces.

Output format: Output the face value of the coin in a line V 1 ≤V 2 ≤… V 1 +V 2 +… K = M + V. Digits are separated by one space. There must be no extra space at the beginning and end of each line. If the solution is not unique, the smallest sequence is output. If there is No Solution, output No Solution.

Note: we say that the sequence {A [1], A [2], and…} than {B [1], [2] B,…} “small”, refers to the existence k p 1 make [I] A [I] = B for all I < k was established, and A [k] < B [k].

Example 1:8 9 5 9 8 7 2 3 4 1 Example 1:1 3 5 Example 2:4 8 7 2 4 3 Example 2: No Solution

Collect small change (30 cents)

#include<stdio.h>  
#include<algorithm>  
#include<vector>  
using namespace std;  
int values[10001],dp[101],choose[10001] [101];  
bool cmp(int a,int b)  
{  
    return a>b;  
}  
int main(a)  
{  
    int i,j,n,m,k,t;  
    scanf("%d %d",&n,&m);  
    for(i=1; i<=n; i++) {scanf("%d",&values[i]);  
    }  
    sort(values+1,values+n+1,cmp);  
    for(i=1; i<=n; i++) {for(j=m; j>=values[i]; j--) {if(dp[j]<=dp[j-values[i]]+values[i])  
            {  
                choose[i][j]=1; dp[j]=dp[j-values[i]]+values[i]; }}}if(dp[m]! =m) {printf("No Solution\n");  
        return 0;  
    }  
    int index=n,sum=m;  
    vector<int> arr;  
    while(sum>0)  
    {  
        if(choose[index][sum]==1)  
        {  
  
           arr.push_back(values[index]);  
           sum-=values[index];  
        }  
        index--;  
    }  
    for(i=0; i<arr.size(); i++) {if(i==0)  
        {  
            printf("%d",arr[i]);  
        }  
        else  
        {  
            printf(" %d",arr[i]); }}printf("\n");  
    return 0;  
}
Copy the code

52. (3n+1) Guess (15 points)

1001 Kill people (3n+1) guess (15 points) Callatz guess:

For any positive integer n, if it is even, cut it in half; If it’s odd, cut 3n plus 1 in half. And you keep doing this over and over and over again, and you’re going to get n equals 1 at some point. Karazi announced the conjecture at the World Congress of Mathematicians in 1950. Legend has it that Yale’s faculty and students were desperately trying to prove this seemingly silly and naive proposition. The result was that the students were distracted from their studies and focused on proving (3n+1), so that some said it was a conspiracy. Karazi was deliberately slowing down the teaching and research of mathematics in the United States…

Our question today is not to prove the Karazs conjecture, but to simply count, for any positive integer n not more than 1000, how many steps (how many cuts) is required to get n=1?

Input format: Each test input contains 1 test case, which gives the value of a positive integer n.

Output format: Displays the number of steps required to calculate from N to 1.

Example Input: 3 Example output: 5

1001 Killing people (3N +1) Guess (15 points)

#include<stdio.h>
int main(a)
{
	int i,j;
	int n;
	int k=0;
	scanf("%d",&n);
	if(n==0) {printf("0");return 0;
	}
	for(i=0;; i++) {if(n%2= =0)
			n/=2;
		else
		{
			n= (3*n+1) /2;
		}
		k++;
		if(n==1)
		break;
	}
	printf("%d",k);
}
Copy the code

53, Write this number (20 marks)

Write down the number (20 points). Read in a positive integer n and count the sum of its digits. Write down each digit of the sum in Pinyin.

Input format: Each test input contains 1 test case, which gives the value of the natural number N. I’m going to make sure that n is less than 10, 100.

Output format: output each digit of the sum of the digits of N in a line, there is 1 space between the pinyin digits, but there is no space after the last pinyin digits in a line.

The input sample: 1234567890987654321123456789 output sample: yi SAN wu

Write the number (20 points).

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int k=0;
	int sum=0,i=0,j;
	char n[1001];
	gets(n);
	int len = strlen(n);
	for(i=0; i<len; i++) { sum+=n[i]-'0';
	}
	//printf("%d\n",sum); // Do I get 135?
	int dayin[10];
	//printf("%d\n",lenght);
	i=0;
	while(sum! =0)
	{
		dayin[i++]=sum%10;
		sum/=10;
	}
	for(j=i- 1; j>=0; j--) {if(j! =0) {switch(dayin[j])
		{
		case 1:printf("yi ");break;
		case 2:printf("er ");break;
		case 3:printf("san ");break;
		case 4:printf("si ");break;
		case 5:printf("wu ");break;
		case 6:printf("liu ");break;
		case 7:printf("qi ");break;
		case 8:printf("ba ");break;
		case 9:printf("jiu ");break;
		case 0:printf("ling ");break; }}else
		{
		switch(dayin[j])
		{
		case 1:printf("yi");break;
		case 2:printf("er");break;
		case 3:printf("san");break;
		case 4:printf("si");break;
		case 5:printf("wu");break;
		case 6:printf("liu");break;
		case 7:printf("qi");break;
		case 8:printf("ba");break;
		case 9:printf("jiu");break;
		case 0:printf("ling");break; }}}return 0;
}
Copy the code

I want to pass! (20 points)

1003 I want to pass! (20 points) “Correct answer” is the most pleasing response from the automated question marking system. The system outputs “correct answer” as long as the string read meets the following conditions. Otherwise, the system outputs “wrong answer”.

The answer is correct if:

The string must contain only P, A, and T characters and cannot contain other characters. “Correct answer” is obtained for any string of the form xPATx, where x is either an empty string or A string consisting only of the letter A; If aPbTc is true, then aPbATca is also true, where a, B, and c are either empty strings or strings consisting only of the letter A. Now write an automatic judge for PAT to determine which strings are “correct”.

Input format: Each test input contains 1 test case. Line 1 gives a positive integer n (<10), which is the number of strings to check. Each string contains a maximum of 100 characters and no Spaces.

Output format: The detection result of each string is one line. If the string can get “correct answer”, the output is YES; otherwise, the output is NO.

8 PAT PAAT AAPATAA AAPAATAAAA xPATx PT Whatever APAAATAA Output Example: YES YES YES NO NO NO NO

1003 I want to pass! (20 points)

#include<stdio.h>
int main(a)
{
    int n;          
    scanf("%d",&n);             
    while(n--){
        char str[110];
        int np=0,nt=0,other=0,lp,lt;
        scanf("%s",str);
        int len=strlen(str);
        for(int i=0; i<len; i++){// Count the number of P,T, and other letters and the positions of P and T
            if(str[i]=='P'){
                np++;
                lp=i;
            }else if(str[i]=='T'){
                nt++;
                lt=i;
            }else if(str[i]! ='A') 
                other++;
        }
        if((np! =1)||(nt! =1)||(other! =0)||(lt-lp<=1)) {// The number of P and T must be one, with no other letters, and at least one A between P and T
            printf("NO\n");
            continue;
        }
        int x=lp,y=lt-lp- 1,z=len-lt- 1;              
        if(x*y==z)
        printf("YES\n");
        else printf("NO\n");
    }
    return 0;

} 
Copy the code

55, Change the format of output integer (15 marks)

Let’s use the letter B for “hundred”, S for “ten”, and 12… N to represent the non-zero one digit number n (<10), reformatted to output any positive integer with no more than three digits. For example, 234 should be printed as BBSSS1234 because it has two hundreds, three tens, and a four in the ones place.

Input format: Each test input contains 1 test case, given as a positive integer n (<1000).

Output format: The output of each test case is one line, and n is output in the specified format.

Example 1:234 Example 1: BBSSS1234 Example 2:23 Example 2: SS123

Output integer (15 marks)

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int n;
	int i=0,j,num=1;
	int k[100] = {0},k1=0;
	scanf("%d",&n);
	while(n! =0)
	{
		k[k1++]=n%10;
		n/=10;
	}
	int ci=k1;
	for(i=k1- 1; i>=0; i--) {if(ci==3)
		{
			while(k[i]--){
				printf("B"); }}else if(ci==2)
		{
			while(k[i]--){
				printf("S"); }}else
		{
			while(k[i]--){
				printf("%d",num);
				num++;
			}
		}	
		ci--;	
	}
	return 0;
}
Copy the code

56. Prime Pair Conjecture (20 points)

Let us define d n as: d n =p n+1 −p n, where p I is the ith prime. Obviously d, 1 is equal to 1, and d, n is even for n>1. The “prime pair conjecture” holds that “there are infinitely many pairs of prime numbers that are adjacent and differ by 2”.

Given any positive integer N(<10 5), please count the number of prime pairs that satisfy the conjecture not exceeding N.

Input format: Input is given a positive integer N on one line.

Output format: Print the number of prime pairs satisfying the guess in a line not exceeding N.

Example Input: 20 Example output: 4

1007 Pairs of prime numbers (20 points)

#include<stdio.h>
#include<math.h>
int main(a)
{
	int i,j;
	int r=0;
	int n;
	int a[2900],k=0;
	scanf("%d",&n);
	for(i=5; i<=n; i+=2)
	{
		for(j=3; j*j<=i; j+=2) {if(i%j==0)
			break;
		}
		if(j==i)
		a[k++]=i;	// Save all primes from 2 to n
	}
	for(i=0; i<k; i++) {if(a[i+1]-a[i]==2)
		r++;	
	}
	printf("%d\n",r);
	
	
	
}
Copy the code

57. Problem with loop right shift of array elements (20 points)

If there are N (>0) integers in array A, move each integer to the right by M (≥0) without allowing the use of another array. That is, the data in A is transformed from (A 0 A 1… A N−1) to (A N−M… A N−1 A 0 A 1… A N−M−1) (the last M numbers are moved to the first M positions in A cycle). If you need to consider moving data as little as possible, how do you design the way to move it?

Input format: Each input contains one test case. Input N (1≤N≤100) and M (≥0) in line 1. Line 2 enters N integers separated by Spaces.

Output format: Output the sequence of integers that have been moved to the right by M bits in a row, separated by Spaces. There must be no extra Spaces at the end of the sequence.

Example Value: 6 2 1 2 3 4 5 6 Example value: 5 6 1 2 3 4

1008 Loop right shift of array elements (20 marks)

#include<stdio.h>
int main(a)
{
	int kr[100],k=0;
	int n,m;
	int i,j;
	scanf("%d%d",&n,&m);
	m%=n;		// if n
	for(i=0; i<n; i++)// Print the beginning of the array
	scanf("%d",&kr[i]);
	for(i=n-m; i<n; i++)printf("%d ",kr[i]);
	for(i=0; i<n-m; i++)//
	{
		if(i! =n-m- 1)
		printf("%d ",kr[i]);
		else
		printf("%d",kr[i]);
	}
	
	/* Second output: very cool and classic */
	/* for (int i = 0; i < N - M - 1; i++) printf("%d ", ary[i]); printf("%d", ary[N - M - 1]); * /
	
	
}
Copy the code

58. Being sarcastic (20 points)

Given a sentence in English, you are asked to write a program that outputs all the words in the sentence in reverse order.

Input format: The test input contains a test case, giving a string of up to 80 total length in one line. The string consists of several words and Spaces. The words are case-sensitive characters separated by one space. Ensure that there is no extra space at the end of the sentence.

Output format: The output of each test case is one line in reverse order.

Example: Hello World Here I Come Example: Come I Here World Hello

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int i=0,j;
	char c;
	char str[100] [100];
	int dan=80;	// Each group of words is entered in positive order, but the subscript is controlled here, so the words are automatically sorted from the end forward
	while((c=getchar())! ='\n')
	{
		if(c==' ')
		{
			str[dan][i]='\ 0';
			dan--;
			i=0;
			continue;
		}
		else
		{
			str[dan][i]=c;
			i++;
		}
	}
	str[dan][i]='\ 0';	// The line breaks out of the loop, so remember to add the terminator to the last word
	for(i=dan; i<80; i++)// The input is in reverse order
	printf("%s ",str[i]);
	printf("%s",str[i]);	// The last word entered has no Spaces
	
}
Copy the code

59, The Derivative of a Unary Polynomial (25 marks)

Derivation of unary Polynomials (25 marks)

Design functions to find derivatives of unary polynomials. (Note: the first derivative of x n (n is an integer) is nx n−1.)

Input format: Input polynomial non-zero coefficients and exponents (absolute values are integers not more than 1000) in exponential descending mode. Numbers are separated by Spaces.

Output format: Output the coefficients and exponents of the non-zero terms of the derivative polynomial in the same format as the input. Digits are separated by Spaces, but there can be no extra space at the end. Note that the “zero polynomial” has both an exponent and a coefficient of 0, but is represented as 0, 0.

Example Value: 3 4-5 2 6 1-2 0 Example value: 12 3-10 1 6 0

Derivation of 1010 Unary Polynomials (25 marks)

#include<stdio.h>
int main(a)
{
	int k=0;
	int xi,zhi;
	while(scanf("%d %d",&xi,&zhi)! =EOF) {if(zhi)	// There is no case where the exponent is 0, so no output is required
		{
			if(k! =0)
			putchar(' ');
			k++;
			printf("%d %d",xi*zhi,zhi- 1);	// The coefficient is multiplied by the exponent, exponent -1}}if(k==0)	// If the derivative is 0, output "0 0"
	printf("0 0\n");
	return 0;
 } 
Copy the code

60, A+B and C (15 分)

A+B and C (15 分)

Given three integers A, B, and C in the range [−2 31,2 31], check whether A+B is greater than C.

Input format: The first line of input gives the positive integer T (≤10), which is the number of test cases. Then group T test cases are given, each group occupies A row, and A, B and C are given in sequence. Integers are separated by Spaces.

Output format: For each set of test cases, print Case #X: true in one line if A+B>C, otherwise print Case #X: false, where X is the test Case number (starting from 1).

Example Input: 4 1 2 3 2 3 4 2147483647 0 2147483646 0-2147483648-2147483647 Example output: Case #1: false Case #2: true Case #3: true Case #4: false

#include<stdio.h>
int main(a)
{
  // The input data is very large, so we should define it as long to ensure that the data is not lost
	int i;
	int k=1;
	long sum=0;
	int n;
	long a,b,c;
	scanf("%d",&n);
	for(i=0; i<n; i++) {scanf("%ld%ld%ld",&a,&b,&c);
		sum=a+b;
			if(sum>c)
			printf("Case #%d: true\n",k);
			else
			printf("Case #%d: false\n",k); k++; }}Copy the code

Creation is not easy, useful please point a thumbs-up, thank you!

61, Prime numbers (20 points)

Let PI be the ith prime number. Given two positive integers M≤N≤10 4, please print all primes from P M to P N.

Input format: Input gives M and N on a single line, separated by Spaces.

Output format: All primes from P M to P N are displayed in one line. Each 10 digits are separated by Spaces. There must be no extra space at the end of the line.

Example Value: 5 27 Example value: 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103

#include<stdio.h>
#include<math.h>
int scnprim(int n);
int main(a)
{	
	int i,m,n,count=0;
	scanf("%d %d",&m,&n);
 
	for(i=2;; i++) {if(scnprim(i))
		{
			count++;
			if(m<=count&&n>=count)
			{	if((count-m+1) %10= =0)
				printf("%d\n",i);
				else if(count! =n)printf("%d ",i);
				else
				printf("%d",i); }}if(n<count)
		{
			break; }}return 0;
}
int scnprim(int n)// Filter prime numbers
{
	int sqrtc,j;
	sqrtc=(int)sqrt(n);
	for(j=2; j<=sqrtc; j++) {if(n%j==0)
			return 0;
 
	}
	return n;
}
Copy the code

62, Theory of Moral ability (25 points)

Sima Guang, a historian of the Song Dynasty, said in his Book “Wisdom of Wisdom” : “It is because of virtue that you are called a sage, a fool, a gentleman and a villain. If you take the art from others, you should get it from a sage or a gentleman. Instead of getting it from a fool, you should get it from a fool.”

Now give a batch of examinees’ scores of virtue and ability, please give admission ranking according to Sima Guang’s theory.

Input format: The first line of input gives three positive integers: N (≤10 5), namely the total number of examinees; L (≥60) is the minimum score for admission, i.e., candidates with German and talent scores of at least L are eligible for admission; H (<100), is the priority line for admission — candidates whose scores are not lower than this line are defined as “just have Full Virtue”, and these candidates are ranked according to their total score of virtue and ability from high to low; Talent score is less than but the German division line of a class of candidates belong to “Desheng talent”, also according to the total score, but ranked after the first class of candidates; The students whose moral and talent scores are all lower than H, but whose moral and talent scores are not lower than H belong to “talent and morality” but still have “morality and talent”, and are ranked after the second group of students according to the total score; Other candidates who reach the lowest line L are also ranked by total score, but are placed below the third category.

Then N lines, each line gives a examinee’s information, including: admission ticket number, German points, where the admission ticket number is an 8-digit integer, German points into the interval [0, 100] integer. Numbers are separated by Spaces.

Output format: The first line of output firstly gives the number of examinees who have reached the minimum score line M, followed by M lines. Each line outputs one examinee’s information according to the input format. Examinees are sorted from high to low according to the rules specified in the input. When more than one type of examinee has the same total score, they will be ranked in descending order of their German score; If German points are also parallel, the admission ticket number in ascending order output.

Example Input: 14 60 80 10000001 64 90 10000002 90 60 10000011 85 80 10000003 85 80 10000004 80 85 10000005 82 77 10000006 83 76 10000007 90 78 10000008 75 79 10000009 59 90 10000010 88 45 10000012 80 100 10000013 90 99 10000014 66 60 Example output: 12 10000013 90 99 10000012 80 100 10000003 85 80 10000011 85 80 10000004 80 85 10000007 90 78 10000006 83 76 10000005 82 77 10000002 90 60 10000014 66 60 10000008 75 79 10000001 64 90

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct Student
{
	int name;	
	int de;
	int cai;
	int sum;
}love1[100100],love2[100100],love3[100100],love4[100100],love5[100100];	// Love1 is the total student
int comp(const void* a,const void* b)
{
	struct Student *aa = (struct Student *)a;
	struct Student *bb = (struct Student *)b;
	if(aa->sum ! = bb->sum)return ((bb->sum) - (aa->sum));
	else if(aa->de ! = bb->de)return ((bb->de) - (aa->de));
	else
	return ((aa->name) - (bb->name));
}
int main(a)
{
	int one=0,two=0,three=0,four=0,five=0;
	int i,j;
	int N,L,H;
	scanf("%d%d%d",&N,&L,&H);
	for(i=0; i<N; i++) {scanf("%d%d%d",&love1[i].name,&love1[i].de,&love1[i].cai);
		love1[i].sum = love1[i].de+love1[i].cai;
	}
	for(i=0; i<N; i++) {if(love1[i].de>=L && love1[i].cai>=L)
		{
			one++;
			if(love1[i].de>=H && love1[i].cai>=H)
			{	love2[two] = love1[i];		two++;		}
			else if(love1[i].cai<H && love1[i].de>=H)
			{	love3[three] = love1[i];	three++;	}
			else if(love1[i].de<H && love1[i].cai<H && love1[i].de>=love1[i].cai)
			{	love4[four] = love1[i];		four++;		}
			else{ love5[five] = love1[i]; five++; }}}printf("%d\n",one);
	qsort(love2,two,sizeof(love2[0]),comp);
	qsort(love3,three,sizeof(love3[0]),comp);
	qsort(love4,four,sizeof(love4[0]),comp);
	qsort(love5,five,sizeof(love5[0]),comp);
	
	for(i=0; i<two; i++)printf("%d %d %d\n",love2[i].name,love2[i].de,love2[i].cai);
	for(i=0; i<three; i++)printf("%d %d %d\n",love3[i].name,love3[i].de,love3[i].cai);
	for(i=0; i<four; i++)printf("%d %d %d\n",love4[i].name,love4[i].de,love4[i].cai);
	for(i=0; i<five; i++)printf("%d %d %d\n",love5[i].name,love5[i].de,love5[i].cai);
}
Copy the code

A divided by B (20 marks)

In this case, calculate A/B, where A is A positive integer with no more than 1000 digits and B is A positive integer with 1 digit. You need to output the quotient Q and remainder R so that A=B×Q+R is true.

Input format: Enter A and B in A row, separated by 1 space.

Output format: Output Q and R in one line, separated by 1 space.

Example Value: 123456789050987654321 7 Example value: 17636684150141093474 3

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int i,j;
	int R,B,Q;
	// remainder, divisor, quotient
	char s[1000010];	/ / dividend
	scanf("%s%d",&s,&B);
	int len = strlen(s);
	Q = (s[0] -'0')/B;
	R = (s[0] -'0')%B;
	if(Q! =0||len==1)      // The divisor is larger than the quotient
		printf("%d",Q); 
	for(i=1; i<len; i++) { Q = (R*10 + s[i]-'0') / B;
		R = (R*10 + s[i]-'0') % B;
		printf("%d",Q); 
	}
	printf(" %d\n",R);
}
Copy the code

64. Hammer, Paper, Scissors (20 points)

You should be able to play the game “Hammer, Paper, Scissors” : Two people give hand signals at the same time, and the rules are shown below:

Now give the record of the battle between the two people, please count The Times of wins, draws and losses of the two sides, and give the best chance for each side to make the gesture.

Input format: The first line of input gives a positive integer N (≤10 5), that is, the number of exchanges between the two sides. Then N lines, each line gives the information of a confrontation, that is, the gesture given by both parties at the same time. C stands for “hammer”, J stands for “scissors”, B stands for “paper”, the first letter stands for Party A, the second letter stands for Party B, with a space in the middle.

Output format: The first and second lines of output give the wins, draws and losses of A and B respectively, separated by a space between the numbers. The third line gives two letters, with a space between them, for the most wins. If the solution is not unique, the smallest solution in alphabetical order is printed.

Example: 10 C J J B C B B B C C C B J B B C J B B C J J 5 3 2 2 3 5 B B 64 MB Code length limit: 16 KB

#include<stdio.h>
int main(a)
{
	int n;
	int i;
	int a=0,b=0,c=0,d=0,e=0,f=0;
	int one=0,two=0,three=0,four=0,five=0,six=0;
	char js,ys;		// Represent a's best move, represent B's best move
	int ping=0;
	char j,y;	// Represent a, B's move
	scanf("%d",&n);
	getchar();
	for(i=0; i<n; i++) {scanf("%c %c",&j,&y);
			 if(j=='C'&&y=='J')
		{ a++;		one++;		}
		else if(j=='J'&&y=='B')
		{	b++;	two++;		}
		else if(j=='B'&&y=='C')
		{	c++;	three++;	}
		else if(j=='B'&&y=='B')
		{		ping++;			}
		else if(j=='J'&&y=='J')
		{		ping++;			}
		else if(j=='C'&&y=='C')
		{		ping++;			}
			 if(y=='C'&&j=='J')
		{ 	d++;	four++;		}
		else if(y=='J'&&j=='B')
		{	e++;	five++;		}
		else if(y=='B'&&j=='C')
		{	f++;	six++;		}
		getchar();
	}
	
	// First judge a's most successful move
	if(one>two&&one>three)
		js='C';
	else if(two>one&&two>three)
		js='J';
	else if(three>one&&three>two)
		js='B';
	else if(two==one&&two>three)
		js='C';
	else if(two==three&&three>one)
		js='B';
	else if(one==three&&two>one)
		js='J';
	else
		js='B';
		
	// Determine b's most successful move
	if(four>five&&four>six)
		ys='C';
	else if(five>four&&five>six)
		ys='J';
	else if(six>four&&six>five)
		ys='B';
	else if(five==four&&five>three)
		ys='C';
	else if(five==six&&six>four)
		ys='B';
	else if(four==six&&five>four)
		ys='J';
	else
		ys='B';
		
		
	printf("%d %d %d\n",a+b+c,ping,(n-(a+b+c+ping)));
	printf("%d %d %d\n",d+e+f,ping,(n-(d+e+f+ping)));
	printf("%c %c\n",js,ys);
	
	
	return 0;
	
	
}
Copy the code

65. Moon cake (25 points)

1020 Moon Cake (25 points)

Mooncakes are a traditional food eaten by Chinese people during the Mid-Autumn Festival. There are many mooncakes with different flavors in different regions. Now given all kinds of mooncake inventory, total price, and the maximum market demand, please calculate the maximum profit you can get.

Note: part of stock is allowed to be withdrawn when selling. An example is given as follows: suppose we have three kinds of moon cakes with inventories of 1.8, 150,000 and 100,000 tons respectively, and total selling prices of 7.5, 7.2 and 4.5 billion yuan respectively. If the market’s maximum demand is only 200,000 tons, then our maximum profit strategy should be to sell all 150,000 tons of type 2 mooncakes and 50,000 tons of type 3 mooncakes, and get 72 + 45/2 = 9.45 billion yuan.

Input format: Each input contains one test case. Each test case starts with a positive integer N not more than 1000 to represent the number of mooncakes and a positive integer D not more than 500 (in tons) to represent the maximum market demand. The following line gives N positive numbers to represent the inventory of each mooncake (in tons); The last line gives N positive numbers for the total price of each mooncake (in hundreds of millions of yuan). Numbers are separated by Spaces.

Output format: For each group of test cases, output the maximum revenue in one line, in hundreds of millions of yuan and accurate to two decimal places.

Example Value: 3 20 18 15 10 75 72 45 Example value: 94.50

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct love{
	double ax;		// Get the unit price of one ton of each mooncake
	double k;		// Get the inventory of each mooncake
	double m;		// The total price of each mooncake
}stu[1000];
int comp(const void* a,const void* b)
{
	struct love *aa = (struct love *)a;
	struct love *bb = (struct love *)b;
	return ((bb->ax)-(aa->ax));		// Members are sorted by unit price
}
int main(a)
{
	int i,j;
	double money=0;
	double n;
	double d;		// Maximum demand
	scanf("%lf",&n);		// There are several kinds of moon cakes
	scanf("%lf",&d);		// Maximum demand
	// Enter the inventory of mooncakes
	for(i=0; i<n; i++) {scanf("%lf",&stu[i].k);
	}
	// Enter the total price of mooncakes
	for(i=0; i<n; i++)scanf("%lf",&stu[i].m);	
	for(i=0; i<n; i++) stu[i].ax = stu[i].m / stu[i].k;// Get the unit price of each mooncake
	qsort(stu,n,sizeof(stu[0]),comp);
	/*printf("%lf %d %d\n",stu[0].ax,stu[0].k,stu[0].m); / / 0 subscript for maximum printf (" % lf % d % d \ n ", stu [1]. The ax, stu [1]. K, stu. [1] m); / / 0 subscript for maximum printf (" % lf % d % d \ n ", stu [2]. The ax, stu [2]. K, stu. [2] m); //0 subscript is Max */
	for(i=0; i<n; i++) {if(d<=stu[i].k)// If the maximum demand is not greater than the current inventory
		{
			money+=stu[i].ax*d;// Maximum revenue is the current unit price multiplied by maximum demand
			break;// Make sure to exit in time
		}
		else
		{
			money+=stu[i].m;// Otherwise, the maximum revenue is added to the current total price
			d-=stu[i].k;// Quantity demanded minus current inventory}}printf("%.2lf\n",money);
}
Copy the code

66. Single digit statistics (15 points)

Given a k-bit integer N=d k−1 10 K −1 +… + D 1 10 1 + D 0 (0≤ D I ≤9, I =0…, K −1, D k−1 >0), write a program to count the number of occurrences of each different one digit. For example, given N=100311, there are two zeros, three ones, and one three.

Input format: Each input contains 1 test case, that is, a positive integer N with no more than 1000 digits.

Output format: For each different one digit in N, output the digit D and the number of times M in N in the format of D:M. The output is required in ascending order of D.

Example Input: 100311 Example output: 0:2 1:33 3:1

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int i,j;
	int x[10] = {0};
	int xing;
	char s[1001];
	gets(s);
	int k = strlen(s);	// Get the length
	for(i=0; i<k; i++) { xing=s[i]- 48;	// Convert a number in a string to an integer number
		x[xing]++;		// use it as an array subscript, corresponding to +1
	}
	for(i=0; i<10; i++)if(x[i]! =0)
		printf("%d:%d\n",i,x[i]);
	return 0;
}
Copy the code

67、 D进制的A+B (20 分)

Input two non-negative 10 base integers A and B (≤2 30 −1), and output the D (1

Input format: Input gives three integers A, B, and D in A row.

Output format: Output the D base number of A+B.

Example Value: 123 456 8 Example value: 1103

#include<stdio.h>
int main(a)
{
	int i,j;
	long  a,b,d;
	long  sum=0;
	int jin[31],k=0;
	scanf("%ld %ld %ld",&a,&b,&d);
	sum = a+b;
	if(sum==0)    // If the sum is equal to 0, output 0 directly, otherwise enter the loop into the pit
	{
	  printf("0");  
	  return 0;
	}
	while(sum! =0)			// Decimal to octal is divided by 8, the remainder of each octal digit is the remainder of each octal digit. When sum=0, the loop is broken
	{
		jin[k++]=sum%d;
		sum/=d;
	}
	for(i=k- 1; i>=0; i--)// When an array outputs octal numbers, pay attention to the reverse output
		printf("%d",jin[i]);
	return 0;
}
		
Copy the code

68, The minimum number of groups (20 points)

Given a number of numbers from 0 to 9. You can arrange the numbers in any order, but you must use them all. The goal is to make the resulting number as small as possible (note that 0 is not the first digit). For example, given two zeros, two ones, three fives, and one eight, the smallest number we can get is 10015558.

Given a number, write a program to output the smallest number that can be composed.

Input format: Input gives 10 non-negative integers in a row, in order to indicate that we have the numbers 0, 1,… The number of 9’s. Integers are separated by a space. The total number of 10 digits cannot exceed 50, and there must be at least one non-0 digit.

Output format: Outputs the smallest number that can be formed in a line.

Input example: 2 2 00 0 3 001 0 Output example: 10015558

Minimum number of groups (20 points)

#include<stdio.h>
int main(a)
{
	int i,j;
	int n;
	int flag = 0;
	int a[10] = {0};
	for(i=0; i<10; i++) {scanf("%d",&a[i]);      // If there is a number at the beginning of 1, print it first. Then print it again
		if(i>=1&& a[i]! =0 && flag>=0)
		{
			printf("%d",i);
			a[i]-=1;
			flag=- 1;
			//	printf("\n-1\n");}}//printf("%d\t%d\t%d\n",a[0],a[1],a[2]);
	for(i=0; i<10; i++) {if(a[i]! =0)
		{
			while(a[i]--)
			printf("%d",i); }}return 0;
}
Copy the code

69, Check id card (15 points)

A valid ID card number consists of a 17-digit area, date and sequence number plus a one-digit verification code. The calculation rules of the verification code are as follows:

First, the first 17 digits are weighted and summed. The weight assignment is: {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; Then modulo the calculated sum with respect to 11 to get the value Z; Finally, the Z value and the check code M are corresponding according to the following relation:

Z: 0 1 2 3 4 5 6 7 8 9 10 M: 10 X 9 8 7 6 5 4 3 2 Now given some ID numbers, please verify the validity of the verification code and output the number in question.

Input format: The first line indicates that N (≤100) is the number of id numbers to be entered. Then N lines, each line gives an 18-digit ID number.

Output format: Output one problematic ID number in each line according to the input sequence. It does not check whether the first 17 bits are reasonable, but only whether the first 17 bits are all digits and the last 1 bit is calculated correctly. If All numbers are normal, All passed is displayed.

Example 1:4 320124198808240056 12010X198901011234 110108196711301866 37070419881216001X Example 1: 12010X198901011234 110108196711301866 37070419881216001X Example 2:2 320124198808240056 110108196711301862 Example 2: All passed

#include <stdio.h>  
#include <stdlib.h>  
   
int charToInt(char c)
{  
     return (int)(c-'0');  
 }  
 int main(int argc, char *argv[]) 
 {  
     int n,i,j,k=0,s,  
     a[]={7.9.10.5.8.4.2.1.6.3.7.9.10.5.8.4.2};  
     char cur,b[11] = {'1'.'0'.'X'.'9'.'8'.'7'.'6'.'5'.'4'.'3'.'2'},  
     c[20];  
     scanf("%d",&n);  
     for(i = 0; i < n; i++) { s=0;  
         scanf("%s",&c);  
         for(j= 0; j<17; j++) {if(c[j]>='0'&&c[j]<='9')
			 {  
                 s+=charToInt(c[j])*a[j];  
			 }
			 else
			 {  
                 printf("%s",c);  
                 if(i<n- 1)
				 {  
                     printf("\n");  
                 }  
                 s=- 1;  
                 break; }}if(b[s%11]==c[j]&&s! =- 1)
		 {  
             k++;  
         }
		 else if(b[s%11]! =c[j]&&s! =- 1)
		 {  
             printf("%s",c);  
             if(i<n- 1)
			 {  
                 printf("\n"); }}}if(k==n)
	 {  
         printf("All passed");  
     }  
     return 0;  
}  
Copy the code

70. Code with Obama (15 points)

US President Barack Obama has become the first US President to write computer code, not only calling for everyone to learn to code, but even leading by example. In late 2014, to mark the official launch of Computer Science Education Week, Obama wrote simple computer code: Draw a square on a screen. Now you can draw with him!

Input format: Enter a line that gives the square edge length N (3≤N≤20) and some character C that makes up the square edge, separated by one space.

Output format: Prints the square drawn by the given character C. But notice that the spacing between rows is larger than the spacing between columns, so to make the result look more square, we actually output the number of rows as 50% of the number of columns (rounded).

Input example: 10 A Output example: AAAAAAAAAA A A A A A A AAAAAAAAAA Author: CHEN, Yue Zhejiang University Time limit: 400 ms Memory limit: 64 MB

Programming with Obama (15 points)

#include<stdio.h>
int main(a)
{
	int i,j,k;
	int n;
	char c;
	int flag=1;
	scanf("%d %c",&n,&c);
	for(i=0; i<n; i++) {printf("%c",c);
	}
	printf("\n");
	for(i=0; i<n4 -; i++) {if(flag==- 1)
		{
			//printf("\n");
			flag=1;
		}
		else
		{
			for(j=0; j<n; j++) {if(j==0||j==n- 1)
				printf("%c",c);
				else
				printf("");
			}
			printf("\n");
			flag=- 1; }}for(i=0; i<n; i++) {printf("%c",c); }}Copy the code

71. Stroke (15 points)

Scratch boxing is an interesting part of ancient Chinese wine culture. The method that two people draw fist on wine table is: each mouth shout out a number, at the same time with hand draw out a number. If the sum of the numbers is exactly equal to the sum of the numbers shouted out by the two people, the winner, the loser fined a drink. If two players win or two players lose, the next round continues until there is a single winner.

Here is the record of a and B, please count how many glasses of wine they drank at last.

Input format: Input a positive integer N (≤100) in the first line, followed by N lines, each line gives a record of a round of strokes, the format is:

A shout a row b shout B row where shout refers to the number shouted, row refers to the number drawn, both are positive integers not more than 100 (both hands row together).

Output format: Output the number of cups a and B drink successively in a line, separated by a space.

Example Input: 5 8 10 9 12 5 10 5 10 3 8 5 12 12 18 1 13 4 16 12 15 Example output: 12

1046 scratch (15 points)

#include<stdio.h>
int main(a)
{
	int i,j;
	int sum=0;
	int a,b,c,d;
	int jia=0,yi=0;
	int n;
	scanf("%d",&n);
	for(i=0; i<n; i++) {scanf("%d%d%d%d",&a,&b,&c,&d);
		sum=a+c;
		if(sum==b&&sum==d)
			continue;
		if(b==sum)
		yi++;
		else if(d==sum)
		jia++;
		sum=0;
	}
	printf("%d %d\n",jia,yi);
	
	
	
}
Copy the code

72, The sum of the number of combinations (15 marks)

Given N non-zero ones digits, any two of them can be combined to form a two-digit number. Find the sum of all possible 2-digit numbers. For example, given 2, 5, 8, the combination can be 25, 28, 52, 58, 82, 85, their sum is 330.

Input format: Input is given N (1 < N < 10) in one line, followed by N different non-zero digits. Numbers are separated by Spaces.

Output format: Outputs the sum of all possible 2-digit numbers.

Example Value: 3 2 8 5 Example value: 330

Sum of the Number of combinations (15 points)

#include<stdio.h>
int main(a)
{
	int i,j;
	int n;
	int sum=0;
	int a[11];
	scanf("%d",&n);
	for(i=0; i<n; i++) {scanf("%d",&a[i]);
	}
	for(i=0; i<n; i++) {for(j=0; j<n; j++)if(i! =j) sum+=a[i]*10+a[j];
	}
	printf("%d\n",sum);
	
	
	
}
Copy the code

73, True or false (15 points)

You should write a simple program to help the teacher judge the questions and count the scores of the students to judge the questions.

Input format: Input in the first line gives two positive integers N and M, not more than 100, respectively the number of students and the number of test questions. The second line gives M positive integers up to 5, the full score for each question. The third line gives the correct answer to each question, with 0 for “no” and 1 for “yes”. And then N rows, each row gives a student’s answer. Numbers are separated by Spaces.

Output format: Output each student’s score in the order of input, each score in a line.

Example: 3 6 2 13 3 4 5 0 0 1 0 1 0 11 0 0 11 0 1 0 11 0 0 11 0 0 11 0 0 11 example: 13 11 12

1061 True Or False questions (15 points)

#include<stdio.h>
int main(a)
{
	int i,j;
	int n,m;
	int a[100];
	int c[100];
	int b[100];
	scanf("%d%d",&n,&m);
	for(i=0; i<m; i++) {scanf("%d",&a[i]);		// Enter the score for each question
	}
	for(i=0; i<m; i++)scanf("%d",&c[i]);
	int x,sum=0;
	for(j=0; j<n; j++) {for(i=0; i<m; i++) {scanf("%d",&x);
			if(c[i]==x) { sum+=a[i]; }}printf("%d\n",sum);
		sum=0; }}Copy the code

74. Image Filtering (15 points)

1066 Image Filtering (15 points) Image filtering is to color the non-important pixels in the image into the background color, so that the important parts are highlighted. Given a black and white image, you are asked to replace all pixel colors within a specified range of gray values with a specified color.

Input format: input gives the resolution of an image in the first line, that is, two positive integers M and N (0

Output format: output filtered images as required. That is, output M lines, each line N pixel gray value, each gray value occupies 3 bits (for example, black to be displayed as 000), separated by a space. There must be no extra space at the beginning or end of a line.

Example: 3 5 100 150 0 3 189 254 101 119 150 233 151 99 100 88 123 149 0 255 Example: 003 189 254 000 000 000 233 151 099 000 088 000 000 000 255

1066 Image Filtering (15 points)

#include<stdio.h>
int main(a)
{
	int i,j;
	int m,n,a,b,c;
	int temp;
	int te[600] [600];
	scanf("%d%d%d%d%d",&m,&n,&a,&b,&c);
	if(a>b)
	{
		temp=a;
		a=b;
		b=temp;
	}
	//printf("%d %d\n",a,b);
	for(i=0; i<m; i++) {for(j=0; j<n; j++) {scanf("%d",&te[i][j]);
			if(te[i][j]>=a&&te[i][j]<=b) { te[i][j]=c; }}}for(i=0; i<m; i++) {for(j=0; j<n- 1; j++) {printf("%03d ",te[i][j]);
		}
		printf("%03d\n",te[i][j]);
	}
	//printf("sda");
	
	
	
}
Copy the code

75. Wifi Password (15 points)

Here is A photo circulating on Weibo: “Dear students, in view of the need to use Wifi sometimes and the fear of delaying your parents’ study, now set the Wifi password to the following math problem answer: A-1; B – 2; C – 3; D – 4; Please write your own answers. change every other day. Thanks for your cooperation!! ~ – Teachers are trying their best to promote students learning. This requires you to write a program to translate the answers to a series of questions into wifi passwords according to the corresponding relationship given on the paper. Here we simply assume that each multiple choice question has four choices, with one and only one correct answer.

Input format: The first line gives a positive integer N (≤ 100), followed by N lines. Each line gives four choices of a question according to the format of number – answer. T indicates correct choice, F indicates wrong choice. Options are separated by Spaces.

Output format: Output wifi password in one line.

Example Input: 8 A-T B-F C-F D-F C-T B-F A-F D-F A-F D-F C-F B-T B-T A-F C-F D-F B-F D-T A-F C-F A-T C-F B-F D-F D-T B-F C-F A-F C-T A-f B-F D-F Example output: 13224143

#include<stdio.h> 
#include<string.h> 
int main(a) { 
		int N; 
		scanf("%d", &N); / / 8
		getchar();
		for (int i = 0; i < N; i++)// One problem at a time
		{ 
			char str[16]; 
			gets(str); // A whole line a-t b-f c-f d-f
			for (int j = 2; j < strlen(str); j += 4) 
				if (str[j] == 'T') 
					printf("%d", str[j - 2] - 'A' + 1); 
	} 
		return 0; 
}
Copy the code

76. Checking passwords (15 points)

1081 Check password (15 points) This question asks you to help a website user registration module to write a password validity check small function. The site requires users to create a password that contains no fewer than six characters and must contain only letters, numbers and a decimal point. It must also contain both letters and numbers.

Input format: Enter a positive integer N (≤ 100) in the first line, followed by N lines. Each line contains a password set by the user. Each line is a non-empty string of up to 80 characters.

Output format: Output system feedback information in one line for each user’s password in the following five types:

If the password is valid, print Your password is wan mei. If the password is too short, print Your password is tai Duan le. If the password is valid but contains invalid characters, the system displays Your password is tai Luan le. If the password length is valid but contains only letters and no numbers, print Your password needs shu zi. If the password length is valid but contains only numbers and no letters, print Your password needs zi mu. Wodepw 1234.5678 WanMei23333 pass*word.6 Example output: Your password is tai duan le. Your password needs shu zi. Your password needs zi mu. Your password is wan mei. Your password is tai luan le.

1081 Checking passwords (15 points)

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int i,j;
	int n,k;
	char s[100];
	int flag=1;
	int shu=0,zi=0,luan=0,duan=0;
	scanf("%d",&n);
	getchar();
	for(i=0; i<n; i++) { gets(s);int len = strlen(s);
		if(len<6)
		{
			printf("Your password is tai duan le.\n");
			continue;
		} 
		for(j=0; j<len; j++) {if((((s[j]>='a'&&s[j]<='z')||(s[j]>='A'&&s[j]<='Z'))||(s[j]>='0'&&s[j]<='9')) = =0&&s[j]! ='. ')
			{
				flag=1;
				break;
			}
			if(flag==2 -&&(s[j]>='a'&&s[j]<='z')||(s[j]>='A'&&s[j]<='Z'))
			{
				flag=4 -;
			}
			else if(flag==- 3&&s[j]>='0'&&s[j]<='9')
			{
				flag=4 -;
			}
			else if(flag! =4 -)
			{
				if(s[j]>='0'&&s[j]<='9')
				{
					flag=2 -;
				}
				else if((s[j]>='a'&&s[j]<='z')||(s[j]>='A'&&s[j]<='Z'))
				{
					flag=- 3; }}}//printf("flag = %d\n",flag);
		if(flag==1)
			printf("Your password is tai luan le.\n");
		else if(flag==4 -)
			printf("Your password is wan mei.\n");
		else if(flag==2 -)
			printf("Your password needs zi mu.\n");
		else if(flag==- 3)
			printf("Your password needs shu zi.\n");
		/*else if(flag==-1) printf("Your password is tai luan le.\n"); * /
		flag=1; }}Copy the code

77. I won’t tell you (15 points)

When you are doing your homework, the child next to you asks you: “What’s five times seven?” You should smile politely and tell him, “Fifty-three.” So they’re asking you, for any given pair of positive integers, to print their product backwards.

Input format: The first line gives two positive integers, A and B, not more than 1000, separated by Spaces.

Output format: Output the product of A and B backwards in one line.

Example Value: 5 7 Example value: 53

1086 won’t tell you (15 points)

#include <stdio.h>
int main(a)
{
	int n1=0,n2=0,mul,count=0,i=0,flag=0; 
	int a[10];
	scanf("%d%d",&n1,&n2);
	mul=n1*n2;
	while(mul>0){
		a[count++]=mul%10;
		mul=mul/10;
	}
	for(i=0; i<count; i++){if(a[i]! =0){
			flag=1;
		}
		if(flag==1) {printf("%d",a[i]); }}return 0;
}
 
Copy the code

78, How many different values are there (20 points)

When the natural numbers n take 1, 2, 3… How many different values of ⌊ N /2⌋+⌊ N /3⌋+ ⌋ N /5 (Note: ⌊x⌋ is an integer function, representing the largest natural number not exceeding x, i.e., the integer part of x.)

Input format: Input gives a positive integer N (2≤N≤10 4).

Output format: Output the number of different values taken by the formula in the problem in a single line.

Example Value: 2017 Example value: 1480

How many different values are there for 1087 (20 points)

#include<stdio.h>
int main(a)
{
	int i,j;
	int n;
	int num;
	int a[10010],k=0;
	scanf("%d",&n);
	for(i=1; i<=n; i++) { num = i/2+i/3+i/5;
		//printf("num = %d\n",num);
		if(i==1)
			a[k++]=num;
		for(j=0; j<k; j++) {if(num==a[j])
				break;
		}
		if(j==k)
			a[k++]=num;
	}
	printf("%d\n",k);
}
Copy the code

79, Dangerous goods packing (25 points)

When shipping goods in containers, we must take special care not to pack incompatible goods in one container. For example, oxidizer must not be packed with flammable liquid, otherwise it is easy to cause explosion.

Given a list of incompatible items, you are asked to check the list of items in each container to see if they fit in the same container.

Input format: The first line of input gives two positive integers: N (≤10 4) is the logarithm of a pair of incompatible items; M (≤100) is the singular of the container list.

The data is then presented in two chunks. The first block has N rows, and each row gives a pair of incompatible items. The second block has M lines, and each line gives a list of one box of goods in the following format:

K G [1] [2] G… G[K] K (≤1000) is the number of items, and G[I] is the number of items. For simplicity, each item is represented by a five-digit number. Separate the two numbers with a space.

Output format: Judge whether the cargo list of each container can be safely transported. Print Yes on a line if there are No incompatible items, No otherwise.

Example Input: 6 3 20001 20002 20003 20004 20005 20006 20003 20001 20005 20004 20004 20006 4 00001 20004 00002 20003 5 98823 20002 20003 20006 10010 3 12345 67890 23333 Example: No Yes Yes

1090 Packing of dangerous goods (25 points)

#include<stdio.h>
struct wu{
 	int wu1;
	int wu2;
}W[20010];
	int main(a){
	 int N,M;
	 scanf("%d%d",&N,&M);
	 int c[100010] = {0};
	 int e;
	 for(int i=0; i<N; i++){int a,b;
	  scanf("%d%d",&a,&b);
	  c[a]++;
	  c[b]++;
	  W[i].wu1=a;
	  W[i].wu2=b;
	 }
	 for(int j=0; j<M; j++){int K;
	  scanf("%d",&K);
	  int flag=0;
	  int b[100010] = {0}; 
	  for(int i=0; i<K; i++){int d;
	   scanf("%d",&d);
	   if(flag==1) {continue;
	   }
	   else if(b[d]==1){
	    flag=1;
	    continue;
	   }
	   else if(c[d]! =0){
	    e=c[d];
	    for(int i=0; i<N; i++){if(d==W[i].wu1){
	      b[W[i].wu2]=1;
	      c[d]--;
	     }
	     else if(d==W[i].wu2){
	      b[W[i].wu1]=1;
	      c[d]--;
	     }
	     if(c[d]==0) {break; } } c[d]=e; }}if(flag==1) {printf("No\n");
	  }
	  else{
	   printf("Yes\n"); }}return 0;
	}
Copy the code

80, N- Defensive number (15 points)

If the last digits of a number K multiplied by N equals K, the number is called “n-defensive”. For example, 3×92 2 =25392, and the last two digits of 25392 are exactly 92, so 92 is a 3-defensive number.

Write a program to determine whether a given number is n-defensive about some N.

Input format: In the first line, the positive integer M (≤20) is given. In the following line, the positive integer M (≤ 1000) to be detected is given.

Output format: Output the smallest N and NK 2 values in a line for each number to be detected if it is n-defensive, separated by a space; Otherwise, output No. Notice that they make sure that N is less than 10.

Example: 392 5 233 Example: 3 25392 1 25 No

N- Defensive number (15 points)

#include<stdio.h>
#include<math.h>
int funtion(int k)
{
	int mix=1;
	while(k)
	{
		mix*=10;
		k/=10;
	}
	return mix;
}
int main(a)
{
	int t;
	int n;
	int i,j;
	int x;
	int avg;
	int ge,shi,bai;
	int flag;
	int sum=0;
	scanf("%d",&n);
	for(i=0; i<n; i++) {scanf("%d",&x);
		t = funtion(x);
		sum = pow(x,2);
		flag=0;
		for(j=1; j<10; j++) { avg = sum*j;/*ge = avg%10; shi = avg/10%10; bai = avg/100%10; * /
			if((avg-x)%t==0)
			{
				printf("%d %d\n",j,avg);
				flag=1;
				break;
			}
			/*else if(x==ge+shi*10) { printf("%d %d\n",j,avg); flag=-1; break; } else if(x==ge+shi*10+bai*100) { printf("%d %d\n",j,avg); flag=-1; break; } * /
		}
		if(flag==0)
			printf("No\n");
		//flag=1;	}}Copy the code

Creation is not easy, useful please point a thumbs-up, thank you!

Creation is not easy, useful please point a thumbs-up, thank you!

81, Programming in C is fun! (5 points)

Programming in C is fun! .

Input format: No input for this topic.

Output format: Output the phrase “Programming in C is fun!” in a single line .

#include<stdio.h>
int main(void)
{
	printf("Programming in C is fun! \n");
}
Copy the code

82. Taxi Fare (15 points)

7-3 Taxi fare (15 points) In this case, a program is written to calculate the fare according to the charging standard of ordinary taxis in a city. Specific standards are as follows:

The starting distance is 3 kilometers and the starting fee is 10 yuan. 2 yuan per kilometer within 10 kilometers after the initial mileage; For the part exceeding 10 km, 50% return subsidy will be charged, namely 3 YUAN per km; In the process of operation, temporary parking due to road obstruction and passengers’ request will be charged at 2 yuan per 5 minutes (less than 5 minutes will not be charged). Input format: Input Indicates the input mileage (in kilometers, accurate to 1 decimal place) and the waiting time (integer, in minutes) on a single line, separated by Spaces.

Output format: Output the fare (in yuan) that the passenger should pay in one line, rounded to yuan.

Example 1: 2.6 2 Example 1: 10 Example 2: 5.1 4 Example 2: 14 Example 3: 12.5 9 Example 3: 34

#include<stdio.h>
int main(a)
{
	double km;			/ / km
	int m=0;			/ / minute
	double money=0;		/ / money
	int yu;
	scanf("%lf %d",&km,&m);
	if(m<5)				// <5 minutes
	{
		if(km<=3)		/ / 0 ~ 3 km
			money=10;
		else if(km<=10)	/ / 3 ~ 10 kilometers
			money=10+(km- 3) *2;
		else			// More than 10 km
			money=10+7*2+(km- 10) *3;
	}
	else
	{
		if(km<=3)		/ / 0 ~ 3 km
			money=10+(m/5) *2;
		else if(km<=10)	/ / 3 ~ 10 kilometers
			money=10+(km- 3) *2+(m/5) *2;
		else			// More than 10 km
			money=10+7*2+(km- 10) *3+(m/5) *2;
	}
	printf("%1.lf\n",money);
	return 0;
}
Copy the code

83, Finding the Partial Sum of power Series Expansion (20 marks)

We know that e x can be expanded as a power series 1+x+x 2/2! +x 3 /3! +. + x k/k! +… Given a real number x, we are asked to use this power series partial sum to approximate e x, and the sum continues until the absolute value of the last term is less than 0.00001.

Input format: input gives a real number x∈[0,5] in a single line.

Output format: Output the partial sum of the power series in one line, with four decimal points reserved.

Example Value: 1.2 Example value: 3.3201

#include<stdio.h>
#include<math.h>
double jiecheng(double n);
int main(a)
{
	double x;		// Enter a real number
	double n=0;		// I'll give you a formula to get the idea, bro
	double c=0;		// to indicate the power
	double sum=0;	/ / o combined
	double result;	// The absolute value of the last term
	scanf("%lf",&x);
	/* * * * * * * * * * * * * * * * * * * * * * * * * + (x ^ 3/3! + (x ^ n/n! * /
	/* There are 5 brackets in each bracket, but all 5 are equal! Do not believe you in the book to calculate ah ^_^ ha ha! * /
	/* Push to the formula: [x^0/0!] + "x 1/1 ^!" + (x ^ 2/2! + "x ^ 3 + 3!" + (x ^ n/n! * /
	do
	{
		result=pow(x,c)/(jiecheng(n));
		sum+=result;
		n++;
		c++;
	}while((jiecheng(n))>=0.00001);
	result=pow(x,c)/(jiecheng(n));
	sum+=result;
	printf("%.4f\n",sum);
	return 0;
}
double jiecheng(double n)
{
	int mix=1;
	for(int i=1; i<=n; i++) mix=mix*i;return mix;
}
Copy the code

84, What is a computer? (5 points)

What is a computer? .

Input format: No input for this topic.

Output format: Output the phrase “What is a computer?” in one line. .

#include<stdio.h>
int main(a)
{
	printf("What is a computer?");
	return 0;
}
Copy the code

85. Assign x squared to Y (5 marks)

Assuming the value of x is 3, compute the square of x and assign the value to Y, and output the values of x and Y as “y = x ∗ x” and “x ∗ x = y”, respectively.

Input format: This topic has no input

Output format: Output x=3 in the following format:

y = x * x

x * x = y

#include<stdio.h>
int main(a)
{
	int x=3;
	int y;
	printf("%d = %d * %d\n%d * %d = %d\n",x*x,x,x,x,x,x*x);
	return 0;
}
Copy the code

86. Calculate the running time of the train (15 minutes)

According to the departure time and arrival time of the train, write a program to calculate the time spent on the whole journey.

Input format: Input gives two 4-digit positive integers in a line, separated by Spaces, indicating the departure time and arrival time of the train respectively. Each time is in the format of a 2-digit hour (00-23) and a 2-digit minute (00-59), assuming departure and arrival are within the same day.

Output format: Displays the time spent on the trip in the format of HH :mm, where HH is the 2-bit hour and mm is the 2-bit minute.

Example Input: 1201 1530 Example output: 03:29

#include <stdio.h>
#include <stdlib.h>
int main(a) 
{
    int h;		/ / hour
	int m;		/ / minute
	int num1;	// Departure time
	int num2;	// Time of arrival
    scanf("%d%d",&num1,&num2);
    h=num2/100-num1/100;            // Take the first two bits (hour)
    m=num2%100-num1%100;            //4位整型取余后2位(分钟)
    if(m<0)                  //num1, num2 are both on the same day, so h must be greater than 0
    {
        m=60+m;                 // When m is less than 0, borrow an hour from h to fill in m
        h=h- 1;
    }
    printf("%02d:%02d\n",h,m);	
	return 0;
}
Copy the code

87, Calculate the salary (15 points)

The wages of employees of a company are calculated as follows: If they work no more than 40 hours in a week, they will be paid according to normal working hours; Working hours in excess of 40 hours will be paid at 1.5 times normal working hours. Employees are divided into new employees and old employees according to the time they have been in the company. Those who have been in the company for at least 5 years are old employees, and those who have been in the company for less than 5 years are new employees. The regular wage for new employees is 30 yuan/hour, and that for old employees is 50 yuan/hour. Please calculate the salary of employees according to this method of payment.

Input format: Enter two positive integers in one line, which are the number of years an employee has been employed and the number of weeks he/she has worked, separated by Spaces.

Output format: Output the employee’s weekly salary in one line, accurate to 2 decimal places.

Input example 1:5 40 Output example 1:2000.00 Input example 2:3 50 Output example 2:1650.00

#include<stdio.h>
int main(a)
{
	int year;					// Year of employment
	int h;						/ / hour
	double money;
	scanf("%d %d",&year,&h);	// Input function
	if(year<5)					// New employees
	{	
		if(h<=40)				// Normal working condition
			money=h*30;
		else					// Overtime
			money=40*30+(h- 40) *1.5*30;
	}
	else						// The situation of the old employees
	{
		if(h<=40)				// Normal working condition
			money=h*50;
		else					// Overtime
			money=40*50+(h- 40) *1.5*50;
	}
	printf("%.2lf\n",money);	
	return 0;
}
Copy the code

88, Day K candle picture (15 points)

Stock prices rise and fall trend, commonly used candle graph technology in the K line to express, divided by the day K line, the week K line, the month K line by the month. A day to day K line as an example, from opening to closing stock price through the day, corresponding to a candle insets, to say four price: opening price Open (just started early in the morning business clinch a deal the price of 1 of the pen), closing price Close (closed in the afternoon of the last sale price), the highest in the middle of the High and Low Low.

If Close<Open, it is “bW-solid” (i.e. “Solid blue and white candle”); If Close>Open, r-hollow; If Open equals Close, it is “R-cross” (” Cross red candle “). If a Low is Lower than Open and Close, it is called a “Lower Shadow”; if a High is higher than Open and Close, it is called an “Upper Shadow”. Program to determine what kind of candle the day is based on a given combination of four prices.

Input format: Four positive real numbers are given in a line, which correspond to Open, High, Low, and Close. They are separated by Spaces.

Output format: Output the type of day K candles in one line. If there are upper and lower lines, add the with line type after the type. If both shadows are present, the output is with Lower Shadow and Upper Shadow.

Example 1:5.110 5.250 5.100 5.105 Example 1: BW-Solid with Lower Shadow and Upper Shadow Example 2:5.110 5.110 5.110 5.110 R-cross Example 3:5.110 5.125 5.112 5.126 Example 3: R-hollow

#include<stdio.h>
int main(a)
{
	double o;		//Open
	double h;		//High
	double l;		//Low
	double c;		//Close
	scanf("%lf%lf%lf%lf",&o,&h,&l,&c);
	if(c<o)
	{
		printf("BW-Solid");
		if(l<o && l<c && h>o && h>c)
			printf(" with Lower Shadow and Upper Shadow");
		else if(l<o && l<c)
			printf(" with Lower Shadow");
		else if(h>o && h>c)
			printf(" with Upper Shadow");
	}
	else if(c>o)
	{
		printf("R-Hollow");
		if(l<o && l<c && h>o && h>c)
			printf(" with Lower Shadow and Upper Shadow");
		else if(l<o && l<c)
			printf(" with Lower Shadow");
		else if(h>o && h>c)
			printf(" with Upper Shadow");
	}
	else if(c==o)
	{
		printf("R-Cross");
		if(l<o && l<c && h>o && h>c)
			printf(" with Lower Shadow and Upper Shadow");
		else if(l<o && l<c)
			printf(" with Lower Shadow");
		else if(h>o && h>c)
			printf(" with Upper Shadow");
	}
	return 0;
}
Copy the code

89. Are you too fat (10 points)

It is said that a person’s standard weight should be the number of kilograms obtained by subtracting 100 from his height in centimetres and multiplying by 0.9. Real weight and standard weight error within 10% are perfect shape (that is, the real weight – standard weight | | < standard weight (10%). We know that a kilo is twice as much as a kilo. Given a group of people’s height and actual weight, please tell them whether they are too fat or too thin.

Input format: The first line of input gives a positive integer N (≤ 20). Then N lines, each of which gives two integers, are a person’s height H (120 < H < 200; Unit: cm) and true weight W (50 < W ≤ 300; Unit: city jin), which is separated by a space.

Output format: output a conclusion for each person: if it is perfect figure, output You are Wan Mei! ; If You are too fat, output You are tai Pang le! ; Otherwise output You are tai shou le! .

Example: 3 169 136 150 81 178 155 Example: You are wan MEI! You are tai shou le! You are tai pang le!

#include<stdio.h>
#include<math.h>
int main(a)
{
	int n;		// Enter a positive integer
	int h;		/ / height
	int w;		// True weight
	int x;		// Standard weight
	/* Standard weight = (height -100) *0.9*0.2 */
	scanf("%d",&n);
	if(n<1 || n>20)		return 0;   //n<=20
	for(int i=1; i<=n; i++) {scanf("%d %d",&h,&w);
		if(h<120 || h>=200 || w<50 || w>300)	return 0;     // 120 < H < 200 and 50 < W ≤ 300
		x = (h- 100.) *0.9*2;
		if(fabs(w-x) < x*0.1)
			printf("You are wan mei! \n");
		else if((fabs(w-x) >= x*0.1) && w<x)
			printf("You are tai shou le! \n");
		else if((fabs(w-x) >= x*0.1) && w>x)
			printf("You are tai pang le! \n");
	}
	return 0;
}
Copy the code

90. Find the smallest string (15 points)

In this case, we need to write a program to output the smallest of N strings.

Input format: The first line of input gives a positive integer N; Each of the following N lines gives a non-empty string of less than 80 length, with no newlines, Spaces, or tabs.

Output format: Output the smallest string in one line in the following format:

Min is: minimum string Example: 5 Li Wang Zha Jin Xian Example: Min is: Jin

7-7 Find the smallest string (15 points)

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
	char a[10000] [80];
	int n;
	int i,j;
	int min;
	char temp[80];
	scanf("%d",&n);
	getchar();
	for(i=0; i<n; i++) gets(a[i]);for(i=0; i<n- 1; i++) { min=i;for(j=i+1; j<n; j++)if(strcmp(a[min],a[j])>0)
				min=j;
			if(min! =i) {strcpy(temp,a[min]);
				strcpy(a[min],a[i]);
				strcpy(a[i],temp); }}printf("Min is: %s",a[0]);
	return 0;
}
Copy the code

91. Bubble sorting of Strings (20 points)

We’ve seen bubble sort for ordering N integers from smallest to largest. For any given K (<N), output the intermediate result sequence after scanning the KTH time.

Input format: N and K are given in line 1 (1≤K

Output format: Output the intermediate result sequence after the bubble sort scanning for the KTH time, each line contains a string.

Example: 6 2 Best cat east a free day Example: Best a cat day east free

7-1 Bubble sort for strings (20 points)

#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(a)
{
	int n,k;			//n→ have several strings, k→ scan several times
	int i,j;			// For loops and array subscripts
	char a[100] [11];	// Used to store strings
	char temp[11];
	scanf("%d%d",&n,&k);	// Input n and k
	getchar();
	for(i=0; i<n; i++)// Provide input string function
		scanf("%s",a[i]);

	for(i=0; i<k; i++) {for(j=0; j<n- 1-i; j++) {if(strcmp(a[j],a[j+1) >0)
			{
				strcpy(temp,a[j]);
				strcpy(a[j],a[j+1]);
				strcpy(a[j+1],temp); }}}for(i=0; i<n; i++)printf("%s\n",a[i]);
	return 0;
}
Copy the code

92, The organization of the week information (10 points)

Enter a positive integer repeat (0<repeat<10) and repeat the following operation:

Define an array of Pointers to organize the following week’s information, enter a string, look in the table, if present, output the string in the table ordinal, otherwise output -1.

Sunday Monday Tuesday Wednesday Thursday Friday Saturday

Input and output Examples: Note in parentheses. No input and output is required

Example Value (repeat=3) : 3 Tuesday Wednesday Year Example value: 3 4-1

7-2 Organization week information (10 points)

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(a)
{
	char *p[] ={"Sunday"."Monday"."Tuesday"."Wednesday"."Thursday"."Friday"."Saturday"};
	int repeat;		// Enter several numbers
	int i,j;		// For loops and array subscripts
	//int flag = 0; // Check if the sentence is output
	char tmp[50];	// The input string
	scanf("%d",&repeat);
	getchar();
	for(i=0; i<repeat; i++) { gets(tmp);for(j=0; j<7; j++) {if(strcmp(tmp,p[j])==0)
			{	printf("%d\n",j+1);	break;	}
			else if(j==6)
				printf("-1\n"); }}return 0;
}
Copy the code

93. Even and Odd (10 points)

Given N positive integers, how many odd and even integers are there?

Input format: The first line of input gives a positive integer N (≤1000); Line 2 gives N non-negative integers, separated by Spaces.

Output format: Output the number of odd numbers and even numbers successively in a line. Separate the names with one space.

Example Value: 9 88 74 101 26 15 0 34 22 77 Example value: 3 6

7-3 Odd and Even Split (10 points)

#include <stdio.h>
#include <math.h>
int main(a)
{
	int n;			// There are several numbers
	int a[1001];	// Space to store data
	int i;		// For loops and array subscripts
	int ji=0,ou=0;	//ji→ count odd numbers, ou→ count even numbers
	scanf("%d",&n);
	for(i=0; i<n; i++)scanf("%d",&a[i]);
	for(i=0; i<n; i++) {if(a[i]%2= =0)
			ou++;
		else
			ji++;
	}
	printf("%d %d\n",ji,ou);
	return 0;
}
Copy the code

94. Pirates’ Spoils (25 points)

P pirates stole D diamonds and went to the high seas to divide the spoils. They agreed on the following strategy:

First, P pirates draw lots to determine the number 1-P. Then, pirate No. 1 proposes a distribution plan (the plan should give the specific amount of each pirate’s share). If an absolute majority (i.e., more than half) including Pirate No. 1 agrees, the distribution plan will be implemented, otherwise, Pirate No. 1 will be thrown into the sea to feed sharks; Then, pirates no. 2, no. 3, and so on, put forward similar proposals in turn, until a plan can be approved by an absolute majority, or there is only one pirate left, who monopolizes all the diamonds. Write a program to give the number of diamonds in pirate 1’s diamond allocation plan.

Three incidental assumptions:

“Smart” and “greedy” assume that each pirate will always act in his own best interest; “Human” assumes that pirates won’t deliberately kill their friends if they can get as many diamonds as possible; “Unbiased” assumes that there is no personal animosity between pirates and that diamonds are distributed to other pirates in the order of small numbers first. Input format: Input gives two positive integers D and P (3≤P≤D≤100) in one line.

Output format: Output the number of diamonds in pirate 1’s diamond allocation scheme.

Example Value: 10 7 Example value: 6

7-9 Pirates’ Spoils (25 points)

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(a)
{
	int d,p;					//d→ number of diamonds, p→ number of diamonds
	scanf("%d %d",&d,&p);		// Provide input diamond, number of functions
    if(p == 3) {printf("%d",d- 1);
    }
    else{
        printf("%d",d-(p/2+1));	When there are more than three people, the first pirate gets gold: D - (P / 2 + 1)
    }
 
 
    return 0;
}
Copy the code

95. Speeding judgment (10 points)

Simulated traffic police radar. Enter the speed of the car. If the speed exceeds 60 MPH, “Speeding” will be displayed, otherwise “OK” will be displayed.

Input format: Input gives a non-negative integer not more than 500 in a line, that is, the speed measured by radar.

Output format: Outputs the speedometer display results in a line in the format of Speed: V-s, where V is the Speed and S is the Speeding or OK.

Example Value 1: Speed: 40 Example value 1: Speed: 40 -OK Example value 2:75 Example value 2: Speed: 75-restricted

7-4 Speeding judgment (10 points)

#include<stdio.h>
int main(a)
{
	int sudu;
	scanf("%d",&sudu);
	if(sudu<=60) {printf("Speed: %d - OK\n",sudu);
	}else{
		printf("Speed: %d - Speeding\n",sudu);
	}
	return 0;
}
Copy the code

96, JMU-DS – Order table interval element deletion (15 marks)

If a linear table L is stored in a sequential storage structure, all of its elements are integers. Design an algorithm to delete all elements whose element values are between [x,y]. The time complexity of the algorithm is O(n) and the space complexity is O(1).

Input format: three rows of data, the first row is the number of elements in the order table, the second row is the elements in the order table, and the third row is X and y.

Output format: delete all elements between [x,y].

Example Value: 10 5 1 9 10 67 12 8 33 6 2 3 10

Example Output: 1 67 12 33 2

Jmu-ds – Order table interval Element deletion (15 marks)

import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int g=0,t=0;
		int x,y;
		int L[]={1.2.3.4.5.6.7.8.9.21213.123.1123.1.132123.123
				,123.132.23.123.12.32.123.123.12.132.123.12.32
				,123.12.132.123.1.23.132.123.312.321
				,12312.32.123.123.1.1231.231.23.123.1321.32
				,12.132.123.132.123.123.132.12.123.123.123.123.1.231.231.231.231.231.21.321.231.231.3
				,1.1.3.1321.1.1.132.123.1.1321.1.32.32.123.123.123.132.23.1321.321.1.23.1
				,123.13.1231.32.231.1.321.123.1.132.123.123.132.123.132.12.132.123.132.132.321.132
		  ,123.23.132.132.132.132.13.213.2.132.1.231.32.132.132.132.132
		  ,23.132.132.132.132.13.213.2.132.1.231.32.132.132.132.13
		  ,23.132.132.132.132.13.213.2.132.1.231.32.132.132.132.13};
		int i,j;
		for(i=0; i<n; i++) L[i]=scanner.nextInt(); x = scanner.nextInt(); y = scanner.nextInt();for(i=0; i<n; i++) {if(L[i]>=x && L[i]<=y)
			{	L[i]=0;}
		}
		for(i=0; i<n; i++)if(L[i]! =0)
				g++;
		for(i=0; i<n; i++) {if(L[i]! =0) {if(t! =g-1)
				System.out.print(L[i] + "");
				elseSystem.out.print(L[i]); t++; }}}}Copy the code

97, Find the specified character (15 marks)

This requires writing a program to find a specified character from a given string.

Input format: The first line of input is a character to be looked up. The second line is a non-empty string (no more than 80 characters) that ends with a carriage return.

Output format: If found, output the maximum subscript of the character in the string in the format “index = subscript” (the subscript starts from 0). Otherwise, “Not Found” is printed.

Input Example 1: M Programming Example 1: index = 7 Input Example 2: A 1234 Output example 2: Not Found

#include<stdio.h>
int main(void)
{
	char c,b[10010];	// The character to be queried, the input character string
	int index=- 1;		/ / tag
	scanf("%c",&c);
	getchar();		// Eats a space, otherwise it will be considered the content of the stringgets(b); Affected by the gets input, the strings all start with \0As the endfor(int i=0; b[i]! ='\ 0'; i++)// So it starts at 0 and ends at = \0
		if(b[i]==c)	// When a character to be queried occurs, it is marked once until the end of the loop
			index=i;
	if(index==- 1)
		printf("Not Found\n");
	else
		printf("index = %d\n",index);
}
Copy the code

98. Four Operations on complex numbers (15 points)

This problem requires writing a program to calculate the sum, difference, product and quotient of two complex numbers.

Input format: Input two complex numbers C1= A1 +b1i and C2=a2+b2i in a row in the format a1, B1, A2, b2. They make sure C2 is not equal to 0.

Output format: Output the sum, difference, product and quotient of the two complex numbers to 1 decimal place respectively in 4 lines in the format of the (A1 +b1i) operator (A2 +b2i) = result. If the real or imaginary part of the result is 0, it is not printed. If the result is 0, 0.0 is printed.

Example 1:2 3.08-2.04 5.06 Example 1: (2.0 + 3.1 I) + (2.0 + 5.1 I) = 8.1 I (2.0 + 3.1 I) – (2.0 + 5.1 I) = 4.0 2.0 (2.0 + 3.1 I) I * (2.0 + 5.1 I) = 19.7 + 3.8 (2.0 + 3.1 I)/I (-2.0+ 5.1I) = 0.4-0.6I Input Example 2:1 1-1-1.01 Output Example 2: (1.0 + 1.0 I) + (1.0-1.0 I) = 0.0 (1.0 + 1.0 I) – (1.0-1.0 I) = 2.0 + 2.0 (1.0 + 1.0 I) I * (1.0-1.0 I) = 2.0 (1.0 + 1.0 I)/I (1.0-1.0 I) = 1.0

Four Operations on Complex numbers (15 points)

#include<stdio.h>
void shizi(double x,double y);		// Print the formula
void result(double x,double y);		// Print the result
struct Love{		
	double shi,xu;	// Represents the real part, imaginary part
}love1,love2;
int main(a)
{	
	scanf("%lf%lf%lf%lf",&love1.shi,&love1.xu,&love2.shi,&love2.xu);
	// The following calculation is based on the real and imaginary parts of the complex number:
	// Find the real and imaginary parts of the addition
	double jia_shi = love1.shi + love2.shi;
	double jia_xu  = love1.xu  + love2.xu;

	// Find the real and imaginary parts of the subtraction method
	double jian_shi = love1.shi - love2.shi;
	double jian_xu  = love1.xu  - love2.xu;

	// Find the real and imaginary parts of the multiplication
	double cheng_shi = love1.shi*love2.shi-love1.xu*love2.xu;
	double cheng_xu  = love1.xu*love2.shi+love1.shi*love2.xu;
	
	// Find the real and imaginary parts of division
	double chu_shi = (love1.shi*love2.shi+love1.xu*love2.xu)/(love2.shi*love2.shi+love2.xu*love2.xu);
	double chu_xu  = (love1.xu*love2.shi-love1.shi*love2.xu)/(love2.shi*love2.shi+love2.xu*love2.xu);
	
	// Since the output of the problem can be divided into several cases, we can judge the case output in the function
	
	/ / add
	shizi(love1.shi,love1.xu);	/ / formulas
	printf("+");
	shizi(love2.shi,love2.xu);	/ / formulas
	printf("=");
	result(jia_shi,jia_xu);		/ / the result

	/ / subtraction
	shizi(love1.shi,love1.xu);	/ / formulas
	printf("-");
	shizi(love2.shi,love2.xu);	/ / formulas
	printf("=");
	result(jian_shi,jian_xu);		/ / the result
	
	/ / the multiplication
	shizi(love1.shi,love1.xu);	/ / formulas
	printf("*");
	shizi(love2.shi,love2.xu);	/ / formulas
	printf("=");
	result(cheng_shi,cheng_xu);		/ / the result

	/ / division
	shizi(love1.shi,love1.xu);	/ / formulas
	printf("/");
	shizi(love2.shi,love2.xu);	/ / formulas
	printf("=");
	result(chu_shi,chu_xu);		/ / the result
	return 0;
}
void shizi(double x,double y)		// Print the formula
{
	if(y<0)							// Do not add '+' when the imaginary part is negative
		printf("(%.1lf%.1lfi)",x,y);
	else
		printf("(%.1lf+%.1lfi)",x,y);	// The reverse is true
}
void result(double rshi,double rxu)
{	
	// If the imaginary part does not exist, just print the real part
	if(rxu<=0.05&&rxu>=0.05)	// If there is neither segment, output 0.0
		printf("%.1lf\n",rshi);
	else if(rshi<=0.05&&rshi>=0.05)	// If the real part does not exist, output a single imaginary part
		printf("%.1lfi\n",rxu);
	else if(rxu<0)
		printf("%.1lf%.1lfi\n",rshi,rxu);	// Do not add the '+' sign when the imaginary part is negative
	else
		printf("%.1lf+%.1lfi\n",rshi,rxu);	// The reverse is true
}
Copy the code

99. Output triangle character array (15 points)

Write A program to output an array of n lines of triangular characters starting with A capital letter A.

Input format: Input is given a positive integer n (1≤n<7) on a single line.

Output format: Output n lines of triangular character array starting with capital letter A. The format is shown in the output sample, where each letter is followed by a space.

Example: 4 Example output: A B C D E F G H I J

Output triangle character array (15 points)

#include<stdio.h>
int main(a)
{
	int n,i,j;
	char x=64;  // Start at A, the ASCLL of A is 65, +1 into the j loop
	scanf("%d",&n);
	for(i=0; i<n; i++)// Control the number of rows
	{
		for(j=0; j<n-i; j++)// Control print
		{ 
			x += 1; // Each time +1, A→65, B→66
			printf("%c ",x);
		}
		printf("\n");
	}
	return 0;
}
Copy the code

100. Find the longest string (15 points)

In this case, we need to write a program to output the longest string of N characters.

Input format: The first line of input gives a positive integer N; Each of the following N lines gives a non-empty string of less than 80 length, with no newlines, Spaces, or tabs.

Output format: Output the longest string in one line in the following format:

If The longest is The same length, The first input string is output.

Example: 5 Li Wang Zhang jin xiang The longest is: Zhang

Find the longest string (15 points)

#include<stdio.h>
#include<string.h>
int main(a)
{
	int n,i;
	char a[100],b[100];	//a→ take input, b→ take the longest string
	scanf("%d",&n);
	getchar();	// Eat the space
	for(i=0; i<n; i++){ gets(a);if(i==0)
			strcpy(b,a);	// The first one needs to be copied to prevent cases where the first one is the longest
		if(strlen(b)<strlen(a))	// If the new one is longer than the old one, copy it to cover the old one
			strcpy(b,a);
	}
	printf("The longest is: ");
	puts(b);
	return 0;
}
Copy the code

Creation is not easy, useful please point a thumbs-up, thank you!

The article directories

    • 1, Hello World (5 分)
    • 2. Print the hourglass (20 points)
    • 3. Single-digit statistics (15 points)
    • 4. Calculate Celsius temperature (5 marks)
    • 5. Seat Number (15 points)
    • 6. Continuous factor (20 points)
    • 7, A-B (20 marks)
    • 8. Calculate the index (5 marks)
    • 9, Calculate the factorial and (10 marks)
    • 10, Simple questions (5 分)
    • 11. Square with Obama (15 points)
    • 12. Checking ID cards (15 points)
    • 13. How many are there (15 points)
    • 14. Big Ben (10 minutes)
    • Who will pour first (15 points)
    • 16. Too handsome to have any friends (20 points)
    • 17. Say important words three times (5 marks)
    • 18. Odd and Even split (10 points)
    • 19. Output GPLT (20 points)
    • 20, The day after tomorrow (5 marks)
    • 21, A+B (15 分)
    • 22, I Love GPLT (5 分)
    • 23. Rent (20 points)
    • 24. Are you too fat (5 points)
    • 25. A gang of one (15 points)
    • 26. Are you too fat? (10 points)
    • 27, Left pad (20 points)
    • 28. Year of Birth (15 points)
    • 29. Thumbs up (20 points)
    • 30. Valentine’s Day (15 points)
    • 31, A times B (5 marks)
    • 32, A divided by B (10 marks)
    • 33. New World (5 points)
    • 34. Ancient Style layout (20 points)
    • 35. Best Height difference between couples (10 points)
    • 36. Looking for 250 (10 points)
    • 37. Date formatting (5 marks)
    • Reading Room (20 points)
    • 39. Sure win (15 points)
    • 40, the universe is invincible hello (5 points)
    • 41. Single (20 points)
    • 42. Pretending to sleep (10 points)
    • 43, MATRIX A times B (15 marks)
    • 44, the NTH string (15 points)
    • 45. Discount (5 points)
    • 46. 2018 We need to win (5 points)
    • 47. Electron Wang (10 points)
    • 48. Who is the winner (10 points)
    • 49. De-weighting linked lists (25 points)
    • 50. Hall of Fame and Vouchers (25 points)
    • 51. Make small change (30 cents)
    • 52. (3n+1) Guess (15 points)
    • 53, Write this number (20 marks)
    • I want to pass! (20 points)
    • 55, Change the format of output integer (15 marks)
    • 56. Prime Pair Conjecture (20 points)
    • 57. Problem with loop right shift of array elements (20 points)
    • 58. Being sarcastic (20 points)
    • 59, The Derivative of a Unary Polynomial (25 marks)
    • 60, A+B and C (15 分)
    • 61, Prime numbers (20 points)
    • 62, Theory of Moral ability (25 points)
    • A divided by B (20 marks)
    • 64. Hammer, Paper, Scissors (20 points)
    • 65. Moon cake (25 points)
    • 66. Single digit statistics (15 points)
    • 67、 D进制的A+B (20 分)
    • 68, The minimum number of groups (20 points)
    • 69, Check id card (15 points)
    • 70. Code with Obama (15 points)
    • 71. Stroke (15 points)
    • 72, The sum of the number of combinations (15 marks)
    • 73, True or false (15 points)
    • 74. Image Filtering (15 points)
    • 75. Wifi Password (15 points)
    • 76. Checking passwords (15 points)
    • 77. I won’t tell you (15 points)
    • 78, How many different values are there (20 points)
    • 79, Dangerous goods packing (25 points)
    • 80, N- Defensive number (15 points)
    • 81, Programming in C is fun! (5 points)
    • 82. Taxi Fare (15 points)
    • 83, Finding the Partial Sum of power Series Expansion (20 marks)
    • 84, What is a computer? (5 points)
    • 85. Assign x squared to Y (5 marks)
    • 86. Calculate the running time of the train (15 minutes)
    • 87, Calculate the salary (15 points)
    • 88, Day K candle picture (15 points)
    • 89. Are you too fat (10 points)
    • 90. Find the smallest string (15 points)
    • 91. Bubble sorting of Strings (20 points)
    • 92, The organization of the week information (10 points)
    • 93. Even and Odd (10 points)
    • 94. Pirates’ Spoils (25 points)
    • 95. Speeding judgment (10 points)
    • 96, JMU-DS – Order table interval element deletion (15 marks)
    • 97, Find the specified character (15 marks)
    • 98. Four Operations on complex numbers (15 points)
    • 99. Output triangle character array (15 points)
    • 100. Find the longest string (15 points)
    • 101, The classification of integers (20 points)
    • 102. Length of Service (20 points)
    • 103, 7-10 Array looping left (20 points)
    • Find the reciprocal KTH term of a chained linear list (20 marks)
    • 105, Square Circle to the right (20 points)
    • 106, The minimum number of groups (20 points)
    • 107. Monkeys eat peaches (15 points)
    • 108, String uppercase conversion (15 points)
    • 109. Calculation of piecewise Functions [3] (10 marks)
    • 110, Find integer (10 marks)
    • 111. Tourism Planning (25 points)
    • Number of Black Holes (20 points)
    • 113. The Hare and the Tortoise (20 points)
    • 114, Spiral square (20 points)
    • 115. Delete substrings from a string (20 points)
    • 116, A-B (20 points)
    • 117, Guess the number (20 points)
    • 118, 40059 Four Operations (15 points)
    • Who is the tallest in the dormitory (20 points)
    • 120. Stepped electricity price (15 points)
    • 121. Speedway penalties (15 points)
    • 122, catch the mouse ah ~ lost or earned? (20 points)
    • 123. Find a ball with a scale (10 points)
    • 124, Find the set of integers that meet the given conditions (15 marks)
    • 125. Count 24 points (25 points) with playing cards
    • 126, Approximate PI (15 marks)
    • 127. A Simple Calculator for Two Numbers (10 points)
    • 128, Introduction to Arithmetic: Addition, Subtraction, Multiplication and Division (10 marks)
    • 129, The NTH string (15 points)
    • 130. Calculating the value of a symbolic function (10 marks)
    • 12-24 hours (15 points)
    • 132. Grade Change (15 points)
    • Finding the number of combinations (15 marks)
    • 134. Output full array (20 points)
    • 135. Magic Coupon (25 points)
    • 136. Find the minimum value (20 points)
    • 137. Input and display of address book (10 points)
    • 138. Calculate how far an object falls (5 points)
    • 139. Time conversion (15 marks)
    • 140. Han Xin Points soldiers (10 points)
    • 141, BCD decryption (10 points)
    • 142. Number of traps (15 points)
    • 143. Simplified Insertion sort (15 points)
    • 144. Comparison of Rational Numbers (10 marks)
    • 145, Calculating the wages of employees (15 points)
    • 146. The Monkey chooses the King (20 points)
    • 147. Three digits in reverse order (10 points)
    • 148. Scoring Rules (5 points)
    • 149. Judges score (5 points)
    • 150, Sum of Special A Series (20 marks)
    • 151. Change coins (20 cents)
    • 152. Drop Ball (20 points)
    • 153, Output student scores (20 points)
    • 154, Find the number of digits and the sum of the digits (15 marks)
    • 155, The simplest fraction (15 marks)
    • 156. I am the Flag Raiser (10 points)
    • 157. RMB exchange (15 marks)
    • 158. Median of two ordered sequences (25 points)
    • 159. Find the student with the highest total score (15 points)
    • 160. Finding the Partial Sum of Simple Staggered Sequences with Given Precision (15 marks)
    • 161. Length of Words (15 marks)
    • 162. Table Output (5 marks)
    • 163. Packing Problems (20 points)
    • Find the first N terms of staggered sequence and (15 marks)
    • 165. Finding the mean square Deviation of Set Data (15 marks)
    • 166. Currency conversion (20 cents)
    • 167. Finding the Local Maximum of the Matrix (15 marks)
    • 168, Check the price of fruit (15 points)
    • 169. Mixed type data Formatting input (5 points)
    • 170, BCD decryption (10 marks)
    • 171. String Pattern Matching (25 points)
    • 179, Integers (5 分)
    • 173. PTA makes me refreshed (5 marks)
    • 174. Temperature conversion (5 marks)
    • 175. Output diamond pattern (5 marks)
    • 176. Fish or meat (10 points)

Creation is not easy, useful please point a thumbs-up, thank you!

101, The classification of integers (20 points)

Given N positive integers, you are required to obtain the following three results:

A1 = The largest integer divisible by 3 A2 = The number of integers with an integer K that can be expressed as 3K+1 A3 = The average (to 1 decimal place) of all integers with an integer K that can be expressed as 3K+2 The input first gives a positive integer N on the first line, followed by N positive integers on the next line. All the digits cannot exceed 100. The digits in the same row are separated by Spaces.

Output format: Outputs the values A1, A2, and A3 in sequence in one line, separated by one space. If a number does not exist, NONE is printed.

Example 1:8 5 8 7 6 9 1 3 10 Example 1:9 3 6.5 Example 2:8 15 18 7 6 9 1 3 10 Example 2:18 3 NONE

Classification of integers (20 points)

#include<stdio.h>
int main(a)
{
	int n,a2=0,a3=0,i,x,max=0,sum=0;
	scanf("%d",&n);
	for(i=0; i<n; i++){scanf("%d",&x);
		if(x%3= =0&&x>max)	// get A1
			max=x;	
		if((x- 1) %3= =0)		// The number of valid ==A2
			a2++;
		if((x2 -) %3= =0)		// The number of valid integers and / ==A3{ a3++; sum+=x; }}if(max==0)	printf("NONE ");	// Output HONE if a1, A2, or a3 is not present
	else		printf("%d ",max);
	if(a2==0)	printf("HONE ");
	else		printf("%d ",a2);
	if(sum==0)	printf("HONE");
	else		printf("%.1f",sum*1.0/a3);
	return 0;
}
Copy the code

102. Length of Service (20 points)

Given the seniority of N employees in a company, the number of employees in each seniority segment is output in ascending order.

Input format: input a positive integer N (≤10 5), that is, the total number of employees; N integers are then given, i.e. the length of service of each employee, ranging from [0, 50].

Output format: Displays the number of employees of each seniority in ascending order, in the format of Seniority: Number of employees. Each term is one row. If the number of people is 0, the item is not printed.

Input example: 8 10 2057 7 52 Output example: 0:1 2:3 5:2 7:1 10:17 7-8 Statistical service years (20 points)

#include<stdio.h>
int main(a)
{
	int i,n,a,b[52] = {0};
	scanf("%d",&n);
	for(i=0; i<n; i++) {scanf("%d",&a);
			b[a]++;
	}
	for(i=0; i<52; i++)if(b[i]! =0)
			printf("%d:%d\n",i,b[i]);

	return 0;
}
Copy the code

103, 7-10 Array looping left (20 points)

Implement a simple function that loops over an array to the left: If there are n (>0) integers in array A, loop each integer to the left by m (≥0) without allowing the use of another array. The data in A is transformed from (A 0 A 1… A N −1) to (A M… A n−1 a 0 A 1… A m−1) (the first M number is moved to the last m positions in a cycle). If you also need to consider moving data as little as possible, how do you design the way you move it?

Input format: Input line 1 gives positive integer n (≤100) and integer m (≥0); Line 2 gives n integers separated by Spaces.

Output format: Output the sequence of integers that have been moved to the left by m bits in a row, separated by Spaces. There must be no extra Spaces at the end of the sequence.

Example Value: 8 3 1 2 3 4 5 6 7 8 Example value: 4 5 6 7 8 1 2 3

7-10 Array looping left (20 points)

#include<stdio.h>
int main(void){
	
	int a[101];
	int n,m,i;
	while(scanf("%d%d",&n,&m)! =EOF){for( i=0; i < n; i++)scanf("%d",&a[i]);
		
		for( i =m; i<n+m; i++){if( i >=n)
			  printf("%d",a[ i%n]);
			else printf("%d",a[i]);
			
			if( i == n+m - 1)
			  printf("\n");
			else printf(""); }}return 0;
}
Copy the code

Find the reciprocal KTH term of a chained linear list (20 marks)

Given a series of positive integers, design an algorithm as efficient as possible to find the number in the KTH position to the last.

Input format: Input begins with a positive integer K, followed by a number of positive integers, and ends with a negative integer (the negative number is not counted in the sequence and is not processed).

Output format: Outputs the data in the KTH position. If the location does not exist, output an error message NULL.

Input example: 4 1 2 3 4 5 6 7 8 9 0-1 Output example: 7

Find the reciprocal KTH term of a chained linear list (20 marks)

#include<stdio.h>
#include<string.h>
#define maxn 0x7fffffff
int a[maxn];
int main(a)
{
    int k;
    scanf("%d",&k);
    int count=0,x;
    while(1)
    {
        scanf("%d",&x);
        if(x<0)break;
        else{ a[count]=x; count++; }}if(count-k<0)
     printf("NULL\n");
    else
     printf("%d\n",a[count-k]); 
    return 0;
}
Copy the code

105, Square Circle to the right (20 points)

In this case, we need to write a program to move each element in a given n× N square matrix to the right by m positions. That is, the 0, 1,…, and N −1 columns are transformed into the N − M, N − M +1,…, N −1, 0, 1,…, and N − M −1 columns.

Input format: The first line of input gives two positive integers m and n (1≤n≤6). Then there are n rows, each row of n integers, representing a square matrix of order n.

Output format: Output the moved square matrix according to the input format: that is, output N lines with n integers in each line and a space after each integer.

Example Value: 2 3 1 2 3 4 5 6 7 8 9 Example value: 2 3 1 5 6 4 8 9 7

7-12 Square Circle to the right (20 points)

#include <stdio.h>
// Time: 20:08:02, April 23rd, 2018
// If you can control the index of the column, you can do it
// The loop prints the two-dimensional array after the loop moves to the right. Because the loop moves to the right, the value m needs to be controlled between 0 and n-1.
int main(a)
{
	int a[10] [10];
	int i, j, n, m;
	scanf("%d%d",&m,&n);
	for (i = 0; i<n; i++)
	{
		for (j = 0; j<n; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	m %= n; // the value of m is less than n, and the value of 0 to n-1 is easy to control the following subscript.
	for (i = 0; i<n; i++)
	{
		for (j = 0; j<n; j++)
		{
			printf("%d ", a[i][(n - m + j) % n]); A [I][(n-m+j) % n] a[I][(n-m+j) % n]
		}
		printf("\n");
	}
	return 0;
}
Copy the code

106, The minimum number of groups (20 points)

Given a number of numbers from 0 to 9. You can arrange the numbers in any order, but you must use them all. The goal is to make the resulting number as small as possible (note that 0 is not the first digit). For example, given two zeros, two ones, three fives, and one eight, the smallest number we can get is 10015558.

Given a number, write a program to output the smallest number that can be composed.

Input format: Input gives 10 non-negative integers in a row, in order to indicate that we have the numbers 0, 1,… The number of 9’s. Integers are separated by a space. The total number of 10 digits cannot exceed 50, and there must be at least one non-0 digit.

Output format: Outputs the smallest number that can be formed in a line.

Input example: 2 2 00 0 3 001 0 Output example: 10015558

Minimum number of groups 7-3 (20 points)

#include<stdio.h>
int main(int argc, char const *argv[])
{
	int i,j;
	int x[9];
	for(i=0; i<10; i++)scanf("%d",&x[i]);
	for(i=1; i<10; i++)if(x[i])
		{	printf("%d",i);  x[i]--;  break;	}
	for(i=0; i<10; i++)while(x[i])
		{	printf("%d",i);	x[i]--;		}
	return 0;
}
Copy the code

107. Monkeys eat peaches (15 points)

A monkey picked a number of peaches on the first day, immediately ate half, not satisfied, and eat one more; The next morning he ate half of the remaining peaches and one more. After that, I ate half of what I had left the day before and one more every morning. To the N day morning to eat again, see only a peach left. Q: How many peaches were picked on the first day?

Input format: Input is given a positive integer N (1

Output format: Output the number of peaches picked on the first day in one line.

Example Input: 3 Example output: 10

7-1 Monkeys eating peaches (15 points)

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int i,j;
	int n;
	int sum=2;
	scanf("%d",&n);
	for(i=1; i<n; i++) {if(i==n- 1)
			sum*=2;
		else
			sum=sum*2+1;
	}
	printf("%d\n",sum);
	return 0;
}
Copy the code

108, String uppercase conversion (15 points)

In this case, you are required to write a program to convert all lowercase letters of a string ending with “#” to uppercase letters and all uppercase letters to lowercase letters. Other characters are output unchanged.

Input format: Enter a string (no more than 30 characters) ending with “#”.

Output format: Output the result string after case conversion in one line.

Example: Hello World! 123# output example: hELLO wORLD! 123

7-2 String uppercase conversion (15 points)

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int i,j;
	char a[10010];
	gets(a);
	int k = strlen(a);
	a[k- 1] = '\ 0';
	for(i=0; a[i]! ='\ 0'; i++) {if(((a[i]>='a'&&a[i]<='z') || (a[i]>='A'&&a[i]<='Z')) = =0)
			continue;
		else if(a[i]>='a'&&a[i]<='z')
			a[i]-=32;
		else
			a[i]+=32;
	}
	puts(a);
	return 0;
}
Copy the code

109. Calculation of piecewise Functions [3] (10 marks)

The following piecewise function f(x) is computed:

Input format: Input gives the real number X on one line.

Output format: F (x) = result in a line, where x and result have a decimal place.

Example 1: F (10.0) = 0.1 Example 2:234 Example 2: F (234.0) = 234.0

Calculation of piecewise Functions [3] (10 marks)

#include<string.h>
#include<stdlib.h>
int main(a)
{
	float x;
	float result=0;
	scanf("%f",&x);
	if(x! =10)
		result = x;
	else
		result = 1/x;
	printf("f(%.1f) = %.1f\n",x,result);
	return 0;
}
Copy the code

110, Find integer (10 marks)

The problem asks to find the given X from the N integers in the input. If found, output the position of X (counting from 0); If Not, “Not Found” is displayed.

Input format: Input gives two positive integers N (≤20) and X in the first line, and N integers in the second line. The number must be no more than a long integer, separated by Spaces.

Output format: Print the position of X in a line, or “Not Found”.

Example 1:5 7 3 5 7 1 9 Example 1:2 Example 2:5 7 3 5 8 1 9 Example 2: Not Found

7-6 Finding integers (10 points)

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int n,x,i;
	int c[10010];
	scanf("%d%d",&n,&x);
	for(i=0; i<n; i++) {scanf("%d",&c[i]);
		if(c[i]==x)
			break;
	}
	if(i==n)
	printf("Not Found\n");
	else
	printf("%d\n",i);
	return 0;
}
Copy the code

111. Tourism Planning (25 points)

With a road map, you’ll know the length of the highway between cities and how much tolls will be charged. Now you need to write a program to help inquiring travelers find the shortest route between their origin and destination. If several paths are shortest, the cheapest path needs to be output.

Input format: Input description: The first line of the input data contains four positive integers N, M, S, and D, where N (2≤N≤500) is the number of cities. Assume that the number of cities ranges from 0 to (N−1). M is the number of highways; S is the city number of the departure point; D is the city number of the destination. In the following M lines, each line gives the information of one expressway, namely, city 1, city 2, expressway length and toll, separated by Spaces. The numbers are all integers and not more than 500. The input guarantees the existence of a solution.

Output format: The length of the output path and the total amount of charges in one line, separated by Spaces, no extra space at the end of the output.

Example: 4 5 0 30 1 1 20 1 3 2 30 0 3 4 10 0 2 2 20 2 3 1 20 Example: 3 40

7-7 Tourism Planning (25 points)

This is a reminder of a competition, I won’t put the correct answer, this is the 17 points code I wrote at the time, just to give you a general idea, if you want full marks for this problem, to di… What of that algorithm can!

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
int main(a)
{
	int cheng1[5010];	1 / / city
	int cheng2[5010];	2 / / city
	int chang[5010];		// The length of the expressway
	int money[5010];		// Total fees
	int i,j;
	int N;	// City number
	int M;	// The number of highways
	int S;	// City number of departure
	int D;	// Destination city number
	int MIN=0;	// Shortest path
	int result=0;	/ / their
	int shangMIN=0;
	int shangResult=0;
	int index;
	scanf("%d%d%d%d",&N,&M,&S,&D);
	for(i=0; i<M; i++)// Enter information for each highway
		scanf("%d%d%d%d",&cheng1[i],&cheng2[i],&chang[i],&money[i]);
	for(i=0; i<M;) {if((cheng1[i]==0)&&(cheng2[i]==N- 1)) { result=money[i]; MIN=chang[i]; index=1; }else
		{
			MIN=chang[i]+chang[i+1];
			result=money[i]+money[i+1];
			index=2;
		}
		if(i==0)
		{
			shangMIN = MIN;
			shangResult=result;
		}
		else
		{
			if(MIN==shangMIN && result<shangResult) { shangMIN=MIN; shangResult=result; }}if(index==1)
			i++;
		else if(index==2)
			i=i+2;
	}
	printf("%d %d\n",shangMIN,shangResult);
	return 0;
}
Copy the code

Number of Black Holes (20 points)

Black hole numbers, also known as trap numbers and “Kaprekar problems”, are a class of numbers with peculiar transformation properties.

Any three-digit number with different digits will always yield 495 after a finite number of rearrangement operations. The resulting 495 is the number of three-position black holes. The so-called “rearrangement difference” operation is the rearrangement of the largest number of the number minus the rearrangement of the smallest number. (6,174 is the number of four-digit black holes.)

For example, for the three-digit number 207:

The difference of the first rearrangement is 720-27 = 693; The second rearrangement is 963-369 = 594; Third rearrangement: 954-459 = 495; It’s going to stay at 495. If all three digits of a three-digit number are the same, it is 0 after one conversion.

Any input of a three – digit, programming gives the process of rearrangement difference.

Input format: Input is given a three-digit number in a line.

Output format: Output the process of rearranging the difference in the following format:

Ordinal number: Maximum number rearranged – Minimum number rearranged = Difference Ordinal number starts at 1 until 495 appears to the right of the equals sign.

Example: 123 Example: 1: 321-123 = 198 2: 981-189 = 792 3: 972-279 = 693 4: 963-369 = 594 5: 954-459 = 495

Number of Black Holes (20 points)

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
int number[6] = {0};
int MAX,MIN;
int sum=0;
int swap2(int x,int y)
{
	if(x<y)
		return x;
	else
		return y;
}
int swap(int x,int y)
{
	if(x>y)
		return x;
	else
		return y;
}
int main(a)
{
	int n;
	int ci=1;
	int i=0,j;
	int index;
	int ge,shi,bai;
	int result;
	scanf("%d",&n);
	index = n;
	while(1)
	{
		ge=index%10;
		shi=index/10%10;
		bai=index/100;
			number[0] = ge + shi*100 + bai*10;
			number[1] = shi + ge*10 + bai*100;
			number[2] = shi + ge*100 + bai*10;
			number[3] = bai + shi*10 + ge*100;
			number[4] = bai + shi*100 + ge*10;
			number[5] = index;
			MAX=number[0];
			MIN=number[0];
		for(i=1; i<6; i++) MAX = swap(number[i],MAX);for(i=1; i<6; i++) MIN = swap2(number[i],MIN); sum = MAX-MIN;printf("%d: %d - %d = %d\n",ci,MAX,MIN,sum);

		ci++;
		index = sum;
		if(sum==495)
			break;
	}
	return 0;
}
Copy the code

113. The Hare and the Tortoise (20 points)

Tortoise and rabbit race, running field is a rectangular runway, runway can rest anywhere. A tortoise can run 3 meters per minute, and a hare 9 meters per minute. The rabbit too slow tortoise run, feel sure to beat the tortoise, so every 10 minutes run back to look at the tortoise, if found himself more than the tortoise, on the roadside rest, rest 30 minutes each time, otherwise continue to run for 10 minutes; But the tortoise worked very hard. He ran all the time and didn’t rest. Suppose the tortoise and the rabbit at the same starting point at the same time start to run, I would like to ask T minutes after the tortoise and rabbit who ran faster?

Input format: Input gives the race time T (minutes) in one line.

Output format: Output the result of the race in one line: turtle wins and output @ @, rabbit wins and output _, tie and output –; Followed by a space to print the distance the winner has run.

Example Input: 242 Example output: @_ @726

7-9 The Tortoise and the Hare (20 points)

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int fen;
	int i,j;
	int gui=0,tu=0;
	int index=0;	// Mark the rabbit rest time
	int swap=1;		// Decide whether the rabbit will continue to run
	scanf("%d",&fen);
	for(i=1; i<=fen; i++) {if(index==30)
		{	index=0;	swap=1;	}
		if(swap! =- 1)
		{
			gui+=3;
			tu+=9;
		}
		else
		{
			gui+=3;
			index++;
		}
		if(i%10= =0)
		{
			if(tu>gui)
				swap=- 1; }}if(gui>tu)
	printf("@_@ %d\n",gui);
	else if(gui==tu)
	printf("-_- %d\n",gui);
	else
	printf("^_^ %d\n",tu);
	//printf("gui = %d,tu = %d\n",gui,tu);
	return 0;
}
Copy the code

114, Spiral square (20 points)

The so-called “spiral square matrix” means that for any given N, the numbers from 1 to N×N are filled into the N×N square matrix in a clockwise spiral direction starting from the first box in the upper left corner. The problem requires the construction of such a spiral matrix.

Input format: Input is given a positive integer N (<10) on one line.

Output format: output N×N spiral matrix. Each row contains N digits, each of which contains 3 digits.

Example: 5 Example: 12 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9

7-4 Spiral square (20 points)

#include<stdio.h>
int main(a)
{
	int n;
	int h=0,l=0;
	int result=1;
	int t;
	int a[100] [100] = {0};
	scanf("%d",&n);
	a[h][l]=1;
	while(n*n! =result) {for(t=result;;)		/ / cross
	{
		if((l+1<n && ! a[h][l+1])! =true)
			break;
		a[h][++l] = ++result;
	}
	for(t=result;;)		/ / vertical
	{
		if((h+1<n && ! a[h+1][l])! =true)
			break;
		a[++h][l] = ++result;
	}	
	for(t=result;;)		/ / cross
	{
		if((l- 1> =0 && !a[h][l- 1])! =true)
			break;
		a[h][--l] = ++result;
	}
	for(t=result;;)		/ / vertical
	{
		if((h- 1> =0 && !a[h- 1][l])! =true)
			break; a[--h][l] = ++result; }}for(h=0; h<n; h++) {for(l=0; l<n; l++)printf("%3d",a[h][l]);
		printf("\n");
	}
	return 0;
}
Copy the code

115. Delete substrings from a string (20 points)

Enter two strings S1 and S2, and delete all substrings S2 that appear in string S1, that is, the result string cannot contain S2.

Input format: Two non-empty character strings with a length of no more than 80 characters and ending with carriage return are given in two lines, corresponding to S1 and S2.

Output format: Output the result string after deleting all substring S2 that occurs in string S1 on one line.

Example: Tomcat is a male CCatat CAT Example: Tom is a male

Delete substrings from a string (20 points)

#include<stdio.h>
#include<string.h>
char a[85],b[85],l,m;
void dete1(char *p,char *q){
   p=strstr(p,q);
   while(*(p+l)! ='\ 0'){
   	*p=*(p+l);
   	*p++;
   }
   *p=*(p+l);
   return ;
}
int main(a){
	int i,j,k;
    gets(a);
    gets(b);
	l=strlen(b);
	while(strstr(a,b)! =NULL){
		 m=strlen(a);
         dete1(a,b); 
	   }
     printf("%s\n",a);
	return 0;
} 
Copy the code

116, A-B (20 points)

They ask you to calculate A−B. The trouble is that both A and B are strings — that is, A−B is formed by removing all the characters contained in B from string A.

Input format: Input gives strings A and B in sequence on 2 lines. Both strings must be no longer than 10 or 4, and each string must consist of visible ASCII characters and whitespace characters, ending with a newline character.

Output format: Print the result string of A−B in one line.

Example: I love GPLT! It’s a fun game! Aeiou Example output: I LV GPLT! It ‘s fn gm!

#include<stdio.h>
#include<string.h>
int main(a)
{
	int i=0,j=0;			// For loops and array subscripts
	char str1[10010];		// Store two strings A and B
	char str2[10010];		// Used to store the string letters to be deleted
	int length;				// To store the length of a string
	gets(str1);
	gets(str2);
	length = strlen(str2);	// Just remember the length of the str2 string
	while(str1[i]! ='\ 0')	// start with str1
	{
		for(j=0; j<length; j++)// Put this letter in str2 and see if there is a corresponding letter, if there is a corresponding letter
		{					// Then the for loop will jump out prematurely, and j cannot be equal to length,
			if(str1[i]==str2[j])// Remember the key words in advance! So we can be sure from this that if the for loop executes
				break;			// At the end of the day, there is no corresponding letter in str2,
		}						// We need to display it.
		if(j==length)
			printf("%c",str1[i]);
		i++;
	}
	printf("\n");
	return 0;
}
Copy the code

117, Guess the number (20 points)

A group of people sit together and each guess a number within 100. Whoever comes closest to half of the average wins. The question is to find the winner.

Input format: Input is given a positive integer N (≤10 4) on the first line. This is followed by N lines, each of which gives a player’s name (a string of up to eight English letters) and its guess of a positive integer (≤ 100).

Output format: Output in order on a line: half of everyone’s average (integer parts only), the name of the winner, separated by Spaces. They guarantee that there’s only one winner.

Example: 7 Bob 35 Amy 28 James 98 Alice 11 Jack 45 Smith 33 Chris 62 Example: 22 Amy

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct E{
char name[11];
int num;
}a[10001];
int main(a){
    int n,sum=0;
    scanf("%d",&n);
    for(int i=0; i<n; i++){scanf("%s%d",a[i].name,&a[i].num);
        sum+=a[i].num;
    }
    int avg=(sum/n)/2,minm=11111,tag;
    for(int i=0; i<n; i++){if(abs(avg-a[i].num)<minm){
            minm=abs(avg-a[i].num); tag=i; }}printf("%d %s\n",avg,a[tag].name);
    return 0;
}
Copy the code

118, 40059 Four Operations (15 points)

Write a priority-free pocket calculator that can add, subtract, multiply and divide.

Input format: for example, keyboard 10.83+0.10/10=.

Output format: output result 1.093000 after program calculation (operation formula ends with ‘=’).

Example: 34.5-2.4 x 3.1/11= Example: 9.722727

#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(a)
{
	int i,j;
	double num1,num2;
	char c;
	scanf("%lf",&num1);
	for(i=0;; i++) {scanf("%c",&c);
		if(c=='=')
		break;
		scanf("%lf",&num2);
		if(c==The '-')
			num1-=num2;
		else if(c=='+')
			num1+=num2;
		else if(c==The '*')
			num1*=num2;
		else if(c=='/')
		{
// if(num2==0)
// num1=0;
// elsenum1/=num2; }}printf("%lf\n",num1);
		return 0;
}
Copy the code

Who is the tallest in the dormitory (20 points)

The school selects basketball players, and each dormitory has a maximum of 4 people. Please find the tallest student in each dormitory. Define a Student class Student with height, weight, and so on.

Input format: Input an integer number n (1<=n<=1000000), representing n students. Then enter n lines in the format of dormitory number, name,height,weight. The dormitory id ranges from 0 to 999999. Name consists of letters and contains less than 16 characters. Height and weight are positive integers.

Output format: Output the information of the tallest student in each dormitory in order of the smallest dormitory number. They ensure that there is only one tallest student in each dormitory.

Example Input: 7 000000 Tom 175 120 000001 Jack 180 130 000001 Hale 160 140 000000 Marry 160 120 000000 Jerry 165 110 000003 ETAF 183 145 000001 Mickey 170 115 Example output: 000000 Tom 175 120 000001 Jack 180 130 000003 ETAF 183 145

#include<math.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct Student{
	int number;
	char name[18];
	int height;
	int weight;
}stu[10010] = {0};
int main(a)
{
	int n;
	int i;
	char temp1[20];
	int index[100],k=0;
	int temp2;
	int number_new;
	char name_new[18];
	int height_new;
	int weight_new;

	scanf("%d",&n);
	for(i=0; i<n; i++) {scanf("%d%s%d%d",&number_new,&name_new,&height_new,&weight_new);
		index[k++]=number_new;
		if(stu[number_new].height == 0)		// Use the serial number to find whether the height has been saved
		{
			stu[number_new].number=number_new;
			strcpy(stu[number_new].name,name_new);
			stu[number_new].height=height_new;
			stu[number_new].weight=weight_new;
		}
		else
		{
			if(height_new>stu[number_new].height)
			{
				stu[number_new].number=number_new;
				strcpy(stu[number_new].name,name_new); stu[number_new].height=height_new; stu[number_new].weight=weight_new; }}}//printf("\n");
	for(i=0; i<k; i++) {if(stu[index[i]].number! =- 1)
		{
		printf("%06d %s %d %d\n",stu[index[i]].number,stu[index[i]].name,stu[index[i]].height,stu[index[i]].weight);
		stu[index[i]].number=- 1; }}//printf("%06d %s %d %d\n",stu[0].number,stu[0].name,stu[0].height,stu[0].weight);
	return 0;
}
Copy the code

120. Stepped electricity price (15 points)

In order to encourage residents to save electricity, the power company of a province implemented the “stepped electricity price”. The electricity price of one household with one meter is divided into two “steps” : the price of electricity within 50 KWH (including 50 KWH) is 0.53 yuan/KWH; If the electricity consumption exceeds 50 KWH, the price will be increased by 0.05 yuan/KWH. Please write a program to calculate the electricity charge.

Input format: Enter the monthly electricity consumption of a user in one line (unit: KWH).

Output format: Output the electricity fee payable by the user (yuan) in one line, with two decimal digits reserved, for example, “cost = value of electricity fee payable”. If the power consumption is less than 0, “Invalid Value!” is displayed. .

Example Value 1: 10 Example value 1: cost = 5.30 Example value 2: 100 Example value 2: cost = 55.50

#include<stdio.h>
int main(a)
{
	double n;
	scanf("%lf",&n);
	if(n<0)
		printf("Invalid Value! \n");
	else if(n<=50)
		printf("cost = %.2lf\n",n*0.53);
	else if(n>50)
		printf("cost = %.2lf\n", (50*0.53+(n- 50) *0.05));
	return 0;
}
Copy the code

Creation is not easy, useful please point a thumbs-up, thank you!

Original is not easy, useful please point a praise, thank you!

121. Speedway penalties (15 points)

According to the regulations, motor vehicles on the expressway, reach or exceed the lane speed limit 10% will be fined 200 yuan; If it reaches or exceeds 50%, the driver’s license will be revoked. Please write a program according to the speed and speed limit automatically judge the processing of the motor vehicle.

Input format: Enter two positive integers in a line, which correspond to the speed and speed limit respectively, separated by Spaces.

Output format: in one line output processing opinion: if it is normal driving, then output “OK”; If a fine is imposed, print “Exceed X %.ticket 200”; If the driving License should be Revoked, “Exceed X %. License Revoked” is output. Where x is the percentage exceeding the speed limit, accurate to the whole number.

Input sample 1: 65 60 Output sample 1: OK Input sample 2: 110 100 Output sample 2: Exceed 10%. Ticket 200 Input sample 3: 200 120 Output sample 3: Exceed 67%. License Revoked

#include<stdio.h>
#include<math.h>
int main(a)
{
	float chesu,xiansu;
	scanf("%f%f",&chesu,&xiansu);
	// If (chesu
	if(chesu-xiansu<xiansu*0.1)
		printf("OK\n");
	else if(chesu<xiansu*1.5)
		printf("Exceed %1.f%%. Ticket 200\n",((chesu-xiansu)/xiansu)*100);
	else
		printf("Exceed %1.f%%. License Revoked\n",((chesu-xiansu)/xiansu)*100);
	return 0;
}
Copy the code

122, catch the mouse ah ~ lost or earned? (20 points)

A mouse disaster, now reward catch mice, every catch a reward of 10 yuan, so began to fight with the mouse wits: every day in the corner can choose the following three operations: place a mouse trap with a piece of cheese (T), or place a piece of cheese ©, or nothing (X). The traps are reusable, regardless of cost, and each piece of cheese costs 3 yuan. What about the smart mouse? They might send a rat to the corner every day to see what’s in the corner:

If there was nothing (X), the mice were Unhappy and had a period of unhappiness lasting up to a day (the next day). Rats are not sent out during periods of displeasure. When the period of unhappiness was over, rats were sent. With a trap, the mouse is enticed to eat the cheese and killed, and the mice have two days of grief (the second and third days). Do not send mice during the period of sorrow. When the sad period was over, rats were sent out. In this case, catching a mouse would earn you $10, but it would also cost you a piece of cheese. Note that if a trap is placed on a given day and the mouse does not appear, no cheese is consumed. If there is cheese ©, the mouse will be Happy to eat the cheese (Happy! , there will be as long as two days (the second and third days) of excitement. During the period of excitement, even if there is added unhappiness or sadness, the rats are bound to be sent. In this case, no mouse was caught and a piece of cheese was used. Note that if the cheese is placed on a given day and the mouse does not appear, the cheese can be used again without cost. Now you are given a sequence of operations for several consecutive days, and it is known that rats will be sent on the first day. Please judge the state of rats every day and calculate profits.

Input format: Input gives contiguous C or T or X strings of up to 70 characters on a single line, ending with $. Each character in the string represents that day’s operation (i.e. X: nothing; T: Rat traps; C: Cheese). The problem guarantees at least one day of operation input.

Output format: Requires a continuous string output on the first line, corresponding to the input, giving the status of the mouse:

! D means that the mice were killed and U means that the mice were not found

  • The second line should output an integer for profit. (If there is a loss, it is negative)

Example 1: TXXXXC$Example 1: D – U-! 4 Input Example 2: CTTCCX$Output Example 2:! DD – U 11

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int money=0;
	int i,j;
	int flag=0,index=0,kong=1;
	int pai=1;
	char s[72];
	gets(s);
	//int len = strlen(s);
	//s[len-1]='\0';
	for(i=0; s[i]! ='$'; i++) {if(flag<=0 && index==0)
		{
			if(s[i]=='X')
			{	printf("U");	index=- 1; pai-=1;	}
			else if(s[i]=='T')
			{	
				if(pai>=1)
				{
					printf("D");	index=2 -;
					money+=7;
					pai-=2; }}else if(s[i]=='C')
			{	
				if(pai>=1)
				{
					printf("!");	flag=2;
					money-=3; }}}else if(flag>0 && kong>=0)
		{
			if(s[i]=='X')
			{	printf("U");		}
			else if(s[i]=='T')
			{	printf("D"); kong--; money+=7;	}
			else if(s[i]=='C')
			{	printf("!"); money-=3; } flag--; }if(kong==- 1)
		{	kong=0;	index=2 -;	}
		while(index<0 && s[i+1]! ='$')
		{
			if(index! =0)
			{
				printf("-");
				++index;
			}
				i=i+1;
				if(pai<1)
				pai++;
		}
		if(pai<1)
		pai++;
	}
	printf("\n%d\n",money);
	return 0;
}
Copy the code

123. Find a ball with a scale (10 points)

Three balls A, B and C are of the same size and shape and one of them has A different weight than the others. I want to find this different ball.

Input format: Input gives three positive integers in A line, corresponding to the weight of ball A, B, and C in the order.

Output format: Output the only different ball in a line.

Example Value: 1 1 2 Example value: C

#include<stdio.h>
int max;
void swap(int a,int b,int c)
{
	max=a;
	if(max! =b&&max==c) { max=b; }else if(max!=c&&max==b)
	{	max=c;	}
}
int main(a)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	swap(a,b,c);
	if(max==a)
		printf("A\n");
	else if(max==b)
		printf("B\n");
	else 
		printf("C\n");
	return 0;
}
Copy the code

124, Find the set of integers that meet the given conditions (15 marks)

Given A positive integer A not exceeding 6, consider four consecutive numbers starting with A. Print all 3-digit numbers that are composed of them without duplicates.

Input format: Input gives an A on A line.

Output format: Output the 3-digit numbers that meet the conditions. Each line contains six integers from the smallest to the largest. Integers are separated by Spaces, but there can be no extra Spaces at the end of the line.

Example Input: 2 Example output: 234 235 243 245 253 254 324 325 342 345 352 354 423 425 432 435 452 453 523 524 532 534 542 543

#include<stdio.h>
int main(a)
{
	int i,j,k;
	int huan_hang=0;	// Control whitespace and line breaks
	int t,n;
	scanf("%d",&t);
	n=t;
	for(i=n; i<=n+3; i++) {for(j=n; j<=n+3; j++) {if(i! =j) {for(k=n; k<=n+3; k++) {if(j! =k&&i! =k) { huan_hang++;// Control whitespace and line breaks
						if(huan_hang<=5)
							printf("%d%d%d ",i,j,k);
						else
							printf("%d%d%d",i,j,k);
						if(huan_hang%6= =0)
						{
							printf("\n");
							huan_hang=0;
						}
					}
				}
			}
		}
	}
	return 0;
}
Copy the code

125. Count 24 points (25 points) with playing cards

Each card in a deck of playing cards represents a number (J, Q, and K represent 11, 12, and 13 respectively, and both commanders represent 6). Take any 4 cards, that is, get 4 numbers from 1 to 13, please add operators (specified as plus + minus – multiply * divide/four) to make it a formula. Each number can only participate in one operation, and the sequence of the four numbers can be arbitrarily combined. Three of the four operators can be arbitrarily taken and repeated. The operation follows a certain priority level, which can be controlled by parentheses. Finally, the operation result is 24. Print an expression for a solution, with parentheses indicating precedence. If there is no solution, the output -1 means no solution.

Input format: Enter four integers in a row. The value of each integer is between [1 and 13].

Output format: Prints an expression for either solution, with parentheses indicating precedence. If no solution exists, output -1.

Example Value: 2 3 12 12 Example value: (3-2) x 12)+12

#include<stdio.h>
#define N 4

// The following function is used to assign four different symbols
static int result(int arr[],char op[]);

// The function that computes the result according to different symbols of different priorities
static double Result(double x, double y, int op);

// The following five functions assign different priorities
//((A op B) op C) op D
static double result1(double num1,double num2,double num3,double num4,int op1,int op2,int op3);
//(A op (B op C)) op D
static double result2(double num1,double num2,double num3,double num4,int op1,int op2,int op3);
//A op (B op (C op D))
static double result3(double num1,double num2,double num3,double num4,int op1,int op2,int op3);
//A op ((B op C) op D)
static double result4(double num1,double num2,double num3,double num4,int op1,int op2,int op3);
//(A op B) op (C op D)
static double result5(double num1,double num2,double num3,double num4,int op1,int op2,int op3);

int main(a)
{			
		int num[N],i,j,k,t;
		char op[5] = {'right'.'+'.The '-'.The '*'.'/'};	// Store all four operators in an array
		for(i=0; i<N; i++)// Enter four numbers at will
			scanf("%d",&num[i]);
		
		// Combine the four digits into different digits
		for(i=0; i<N ; i++) {for(j=0; j<N; j++) {if(i==j) continue;
				for(k=0; k<N; k++) {if(i==k || j==k) continue;
					for(t=0; t<N; t++) {if(i==t || j==t || k==t) continue;
						int zuhe_num[N] = {num[i],num[j],num[k],num[t]};	/* The four numbers appear in different order, because of the different operators, so the calculation results are naturally different */
						int swap =	result(zuhe_num,op);	// If there is a set of data that is valid for 24, then it ends
						if(swap)// If there is a solution, end the program directly
						{
							return 0;
						}
						
					}
				}
			}	
		}
		/ / there is no solution
		printf("1");	
}
static int result(int zuhe_num[],char op[])	// The following function is used to assign four different symbols
{
		double sum =0;
		// enumerate all combinations of operations
		for(int i=1; i<=N; i++) {for(int j=1; j<=N; j++) {for(int k=1; k<=N; k++) { sum = result1(zuhe_num[0],zuhe_num[1],zuhe_num[2],zuhe_num[3],i,j,k);
					if(sum==24)		// If the conditions are met, the output is direct, and return 1 to end the program, and so on
					{
						//((A op B) op C) op D
						printf("((%d%c%d)%c%d)%c%d\n",zuhe_num[0],op[i],zuhe_num[1],op[j],zuhe_num[2],op[k],zuhe_num[3]);
						return 1;
					}
					sum = result2(zuhe_num[0],zuhe_num[1],zuhe_num[2],zuhe_num[3],i,j,k);
					if(sum==24)
					{
						//(A op (B op C)) op D
						printf("(%d%c(%d%c%d))%c%d\n",zuhe_num[0],op[i],zuhe_num[1],op[j],zuhe_num[2],op[k],zuhe_num[3]);
						return 1;
					}
					sum = result3(zuhe_num[0],zuhe_num[1],zuhe_num[2],zuhe_num[3],i,j,k);
					if(sum==24)
					{
						//A op (B op (C op D))
						printf("%d%c(%d%c(%d%c%d))\n",zuhe_num[0],op[i],zuhe_num[1],op[j],zuhe_num[2],op[k],zuhe_num[3]);
						return 1;
					}
					sum = result4(zuhe_num[0],zuhe_num[1],zuhe_num[2],zuhe_num[3],i,j,k);
					if(sum==24)
					{
						//A op ((B op C) op D)
						printf("%d%c((%d%c%d)%c%d)\n",zuhe_num[0],op[i],zuhe_num[1],op[j],zuhe_num[2],op[k],zuhe_num[3]);
						return 1;
					}
					sum = result5(zuhe_num[0],zuhe_num[1],zuhe_num[2],zuhe_num[3],i,j,k);
					if(sum==24)
					{
						//(A op B) op (C op D)
						printf("(%d%c%d)%c(%d%c%d)\n",zuhe_num[0],op[i],zuhe_num[1],op[j],zuhe_num[2],op[k],zuhe_num[3]);
						return 1; }}}}// If there is no solution
		return 0;
}
static double Result(double num1, double num2, int op)		// The function that computes the result according to different symbols of different priorities
{
	if(op==1)		// Make a judgment based on the passed symbol, and perform the corresponding calculation
		return num1+num2;
	else if(op==2)
		return num1-num2;
	else if(op==3)
		return num1*num2;
	else if(op==4)
		return num1/num2;
	else
		return 0;
}
// The following five functions assign different priorities
static double result1(double num1,double num2,double num3,double num4,int op1,int op2,int op3)	
{														//((A op B) op C) op D
		double r1,r2,r3;
		r1 = Result(num1,num2,op1);
		r2 = Result(r1,num3,op2);
		r3 = Result(r2,num4,op3);
		return r3;
}
static double result2(double num1,double num2,double num3,double num4,int op1,int op2,int op3)
{														//(A op (B op C)) op D
		double r1,r2,r3;
		r1 = Result(num2,num3,op2);
		r2 = Result(num1,r1,op1);
		r3 = Result(r2,num4,op3);
		return r3;
}
static double result3(double num1,double num2,double num3,double num4,int op1,int op2,int op3)
{														//A op (B op (C op D))
		double r1,r2,r3;
		r1 = Result(num3,num4,op3);
		r2 = Result(num2,r1,op2);
		r3 = Result(num1,r2,op1);
		return r3;	
}
static double result4(double num1,double num2,double num3,double num4,int op1,int op2,int op3)
{														//A op ((B op C) op D)
		double r1,r2,r3;
		r1 = Result(num2,num3,op2);
		r2 = Result(r1,num4,op3);
		r3 = Result(num1,r2,op1);
		return r3;
}

static double result5(double num1,double num2,double num3,double num4,int op1,int op2,int op3)
{														//(A op B) op (C op D)
		double r1,r2,r3;
		r1 = Result(num1,num2,op1);
		r2 = Result(num3,num4,op3);
		r3 = Result(r1,r2,op2);
		return r3;
}
Copy the code

126, Approximate PI (15 marks)

In this case, a program is required to approximate PI according to the following formula until the last term is less than the given precision EPS.

Input format: The input gives the precision EPS in one line. The input can be read using the following statements:

scanf(“%le”, &eps); Output format: In a single line, print an approximation of π (with 5 decimal places reserved) in the following format:

PI = Approximate Value Input example: 1E-5 Output example: PI = 3.14158

#include<stdio.h>
double fenzi(int n);
double fenmu(int n);
int main(a)
{
	int n=0;
	double sum=0;
	double eps;
	scanf("%le",&eps);
	do
	{
		sum+=fenzi(n)/fenmu(n);
			  		n++;
	}while((fenzi(n)/fenmu(n))>=eps);
	if(sum>=eps)
	sum+=fenzi(n)/fenmu(n);
	printf("PI = %.5lf", sum * 2);
	return 0;
}
double fenzi(int n)
{
	if(n==0)
	return 1;
	
	return n*fenzi(n- 1);
}
double fenmu(int n)
{
	if(n==0)
	return 1;
	
	return (n*2+1) * fenmu(n- 1);
}
Copy the code

127. A Simple Calculator for Two Numbers (10 points)

This requires a simple calculator program that can add, subtract, multiply, divide or complement two integers according to the input operators. The problem ensures that neither input nor output exceeds the range of integers.

Input Format: Enter operand 1, operator, and operand 2 in a row, separated by one space. The data type of the operands is integer and the denominator of the division and remainder is guaranteed to be non-zero.

Output format: When the operators are +, -, *, /, and %, the corresponding operation results are output in one line. If the input is an invalid symbol (that is, any symbol other than the five operators addition, subtraction, multiplication, division, and remainder), ERROR is printed.

Example Input 1: -7/2 Example output 1: -3 Example input 2:3&6 Example output 2: ERROR

#include<stdio.h>
int main(int argc,char* argv[])
{
	int num1,num2;
	char c;
	scanf("%d %c %d",&num1,&c,&num2);
	switch(c)
	{
		case '+':printf("%d\n",num1+num2);break;
		case The '-':printf("%d\n",num1-num2);break;
		case The '*':printf("%d\n",num1*num2);break;
		case '/':printf("%d\n",num1/num2);break;
		case The '%':printf("%d\n",num1%num2);break;
		default :printf("ERROR\n");
	}
	return 0;
}
Copy the code

128, Introduction to Arithmetic: Addition, Subtraction, Multiplication and Division (10 marks)

For two integers input, output their sum and difference product as required.

Input format: Enter two non-negative integers a and b that cannot exceed 100 on a line separated by a space. Ensure that b is not 0.

Output format: four lines in total, in the following format:

[a] + [b] = [a+b]

[a] – [b] = [a-b]

[a] * [b] = [a*b]

[a] / [b] = [a/b]

The contents with square brackets (for example, [a], [b], and [a+b]) represent the corresponding integer or the value of the operation result, which should be replaced by the actual value in output.

If a is divisible by B, a/b should be printed as an integer. Otherwise, a/ B should be printed as a two-digit decimal.

Tip: Note the whitespace in the expression.

Example Input 1: 6 3 Example Output 1: 6 + 3 = 9 6-3 = 3 6 x 3 = 18 6/3 = 2 Example input 2: 8 6 Example output 2: 8 + 6 = 14 8-6 = 2 8 * 6 = 48 8/6 = 1.33

#include<stdio.h>
int main(int argc,char* argv[])
{
	int num1,num2;
	scanf("%d%d",&num1,&num2);
	printf("%d + %d = %d\n",num1,num2,num1+num2);
	printf("%d - %d = %d\n",num1,num2,num1-num2);
	printf("%d * %d = %d\n",num1,num2,num1*num2);
	double result = (num1*0.1/num2)*10;
	if(result == (int)result)
	printf("%d / %d = %d\n",num1,num2,num1/num2);
	else
	printf("%d / %d = %.2lf\n",num1,num2,result);
	return 0;
}
Copy the code

129, The NTH string (15 points)

Given an arithmetic increasing sequence of strings consisting entirely of lowercase English letters, each string in the sequence has a fixed length of L, starting with L as and increasing by 1 step. For example, when L is 3, the sequence is {aaa, aab, aac… , AAZ, ABA, ABB… Abz,… , z}. The 27th string from the end of the sequence is zyz. For any given L, they’re asking you to give them the NTH to the last string from the corresponding sequence.

Input format: Input gives two positive integers L (2 ≤ L ≤ 6) and N (≤10 5) in a single line.

Output format: Output the NTH penultimate string of the corresponding sequence in one line. They guarantee that this string exists.

Input example: 3 7417 Output example: PAT

#include<stdio.h>
#include<math.h>
#define L 6

int main(a)
{
	char ch[26] = {'z'.'y'.'x'.'w'.'v'.'u'.'t'.'s'.'r'.'q'.'p'.'o'.'n'.'m'
	             ,'l'.'k'.'j'.'i'.'h'.'g'.'f'.'e'.'d'.'c'.'b'.'a'};
	char arr[L];
	int n,l,a,i;         //l is the length of the sequence, n is the position of the sequence in reverse order, and a is the position of a character of the desired string in the ch array
	scanf("%d %d",&l,&n);
	n=n- 1;               // The last character is correct after subtracting 1
	for(i=0; i<l; i++) { a=n/pow(26,l-i- 1);
		arr[i]=ch[a];
		n=n-a*pow(26,l-i- 1);
	}
	for(i=0; i<l; i++) {printf("%c",arr[i]);
	}
	return 0;
 }
Copy the code

130. Calculating the value of a symbolic function (10 marks)

For any integer n, the sign function sign(n) is defined as follows:

Write a program to calculate the value of this function for any input integer.

Input format: Input is given an integer N in a line.

Output format: Output the function value of the integer n according to the format “sign(n) = function value”.

Example Example 1: sign(10) = 1 Example 2: 0 Example 2: sign(0) = 0 Example 3: -98 Example 3: sign(-98) = -1

#include<stdio.h>
int main(int argc,char* argv[])
{
	int n;
	int result;
	scanf("%d",&n);
	if(n<0)
	result=- 1;
	else if(n==0)
	result=0;
	else
	result=1;
	printf("sign(%d) = %d",n,result);
	return 0;
}
Copy the code

12-24 hours (15 points)

Write a program that asks the user to enter a 24-hour time and then displays a 12-hour time.

Input format: Enter the 24-hour time given in a line with the middle: sign (semicolon), e.g. 12:34 for 12:34. When the number of hours or minutes is less than 10, there is no leading zero. For example, 5:6 means 5:06.

Tip: Add: to scanf’s format string and let scanf handle the colon.

Output format: Print the 12-hour time corresponding to this time on a single line in the same numeric format as the input, followed by a space, followed by the string AM for the morning or PM for the afternoon. For example, 5:6pm means 5:06pm. Note that in English custom 12 noon is considered afternoon, so 12 o ‘clock in the 24-hour system is 12 o ‘clock in the 12-hour system; And 0 o ‘clock is considered the time of the next day, so 0:0 AM.

Example Input: 21:11 Example output: 9:11 PM

#include<stdio.h>
int main(a)
{
	int h,m;
	scanf("%d:%d",&h,&m);
	if(h<=12)
	{
		if(h<12)
		printf("%d:%d AM\n",h,m);
		else
		printf("%d:%d PM\n",h,m);
	}
	else
	{
		if(h<24)
		printf("%d:%d PM\n",h- 12,m);
		else
		printf("%d:%d AM\n",h,m); }}Copy the code

132. Grade Change (15 points)

Write a program to convert a 100-point score into a five-point score. Conversion rules:

Greater than or equal to 90 is divided into A; B is less than 90 and greater than or equal to 80; C is less than 80 and greater than or equal to 70; Less than 70 and greater than or equal to 60 is D; Less than 60 is E. Input format: Input gives a percentage score of an integer in a line.

Output format: Output the corresponding five-point score in one line.

Example Input: 90 Example output: A

#include<stdio.h>
int main(a)
{
	int n;
	scanf("%d",&n);
	if(n>=90)
	printf("A\n");
	else if(n>=80)
	printf("B\n");
	else if(n>=70)
	printf("C\n");
	else if(n>=60)
	printf("D\n");
	else
	printf("E");
}
Copy the code

Finding the number of combinations (15 marks)

So they’re going to write a program based on the formula



Figure out the number of combinations that take m elements out of n distinct elements (m≤n).

It is recommended to define and call the function fact(n) to calculate n! , where n is of type int and the function type is double.

Input format: Two positive integers m and n (m≤n) are separated by Spaces.

Output format: The output is in the format result = Number of combinations calculated result. They guarantee that the result is in the range of double.

Example Value: 2 7 Example value: result = 21

#include<stdio.h>
double jiecheng(int x);
int main(a)
{
	int n,m;
	scanf("%d%d",&m,&n);
	double result = jiecheng(n)/(jiecheng(m)*jiecheng(n-m));
	printf("result = %1.lf",result);
	return 0;
}
double jiecheng(int x)
{
	double mix=1;
	if(x==0)
		return 1;
	for(int i=2; i<=x; i++) mix*=i;return mix;
}
Copy the code

134. Output full array (20 points)

Write a program to output all permutations of the first n positive integers (n<10), and observe the running time of the program as n increments through nine test cases (n from 1 to 9).

Input format:

The input gives a positive integer n (<10).



Example Input:

3

Example output:

123

132

213

231

312

321

#include <stdio.h>
int a[10],b[10],n;
void dfs(int step){
    if (step==n+1) {for (int i=1; i<=n; i++)printf("%d",a[i]);
        printf("\n");
        return;
    }
    for (int i=1; i<=n; i++){if (b[i]==0){
            a[step]=i;
            b[i]=1;
            dfs(step+1);
            b[i]=0; }}return;
}
int main(a){
    scanf("%d",&n);
    dfs(1);
    return 0;
}
Copy the code

135. Magic Coupon (25 points)

There’s a magic store on Mars that offers magic coupons. Each coupon is printed with an integer value K, which means that if you use the coupon to buy something, you will get K times the value of the product! The store also gives away some valuable items for free, but if you use a coupon with a positive face value when you receive the freebies, you have to give the store K times the value of the item… But never mind, there are coupons with negative face values to use! (Amazing Mars)

For example, given a set of coupons with face values of 1, 2, 4, and -1. Corresponding to a group of goods, the value is Mars coin M$7, 6, -2, -3, where the negative value indicates that the goods are freebies. We can apply coupon 3 to good 1 and get M$28; Coupon 2 is used on good 2, so you get M$12; Coupon 4 is used on good 4, so you get M$3 back. But if you accidentally use coupon 3 on item 4, you have to pay the store M$12. Similarly, when you accidentally use coupon 4 on item 1, you must pay the store M$7.

Limit each coupon and item to a maximum of one use to maximize the return you can get.

Input format: Input has two lines. The first line gives the number of coupons, N, followed by the integer values of N coupons. The second line first gives the number of items, M, followed by the integer value of M items. N and M are between [1, 10, 6]. The size of all data cannot exceed 2 or 30. Digits are separated by Spaces.

Output format: Output can get the maximum return.

Example Input: 4 1 2 4-1 4 7 6-2-3 Example output: 43

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int yh[1000001];
int hx[1000001];
int comp(const void* num1,const void* num2)
{
	return* (int*)num2 - *(int*)num1;
}
int main(a)
{
	int N,M;
	int sum=0;
	int i,j;
	scanf("%d",&N);
	for(i=0; i<N; i++)scanf("%d",&yh[i]);
	scanf("%d",&M);
	for(i=0; i<M; i++)scanf("%d",&hx[i]);
	qsort(yh,N,sizeof(int),comp);
	qsort(hx,M,sizeof(int),comp);
	for(i=0,j=0; i<N&&j<M; i++,j++)
	{
			if(yh[i]>0&&hx[j]>0)
				sum+=yh[i]*hx[j];
	}
	for(i=N- 1,j=M- 1; i>=0&&j>=0; i--,j--) {if(yh[i]<0&&hx[j]<0)
				sum+=yh[i]*hx[j];
	}
	printf("%d\n",sum);
	return 0;
}
Copy the code

136. Find the minimum value (20 points)

The problem requires writing a program to find the smallest value in a given series of integers.

Input format: Input is given a positive integer N on a line, followed by n integers separated by Spaces.

Output format: Outputs the minimum value of n integers in the format “min = min” in a line.

Example Value: 4-2-123 100 0 Example value: min = -123

#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int comp(const void* a,const void* b)
{
	return* (int*)a-*(int*)b;
}
int main(void)
{
	int i,j,a[1000];
	int min;
	int n;
	scanf("%d",&n);
	for(i=0; i<n; i++) {scanf("%d",&a[i]);
	}
	qsort(a,n,sizeof(int),comp);
	printf("min = %d",a[0]);
	return 0;
}
Copy the code

137. Input and display of address book (10 points)

A record in the address book contains the following basic information: the friend’s name, date of birth, gender, landline number and mobile phone number. In this case, the program is required to input N records, and display any one of the records according to the requirements.

Input format: Input is given a positive integer N (≤10) on the first line; Then N lines, each line according to the format name birthday gender fixed-line mobile phone to give a record. The name is a non-empty string containing no Spaces and no more than 10 characters. Birthdays are given in yyyy/mm/ DD format. The gender is M for male and F for female. Both fixed-line and mobile phones are consecutive digits of up to 15 digits, which may be preceded by +.

After the address book records are entered, the last line gives a positive integer K, followed by K integers, indicating the numbers of the records to be queried (numbered from 0 to N−1). Numbers are separated by Spaces.

Output format: For each record to be queried, output the record in the format of name, fixed-line phone, gender, date of birth in one line. If the record to be queried does Not exist, “Not Found” is displayed.

Example Input: 3 Chris 1984/03/10 F +86181779452 13707010007 LaoLao 1967/11/30 F 057187951100 +8618618623333 QiaoLin 1980/01/01 M 84172333 10086 2 17 Example: LaoLao 057187951100 +8618618623333 F 1967/11/30 Not Found

#include<stdio.h>
struct Stu{
	char name[11];
	char year[11];
	char sex[2];
	char phone[17];
	char telephone[17];
}love[100];
int main(a)
{
	int i,j;
	int n;
	scanf("%d",&n);
	getchar();
	for(i=0; i<n; i++) {scanf("%s%s%s%s%s",&love[i].name,&love[i].year,&love[i].sex,&love[i].phone,&love[i].telephone);
	}
	int x;	// Query number s
	scanf("%d",&x);
	int cha;
	for(i=0; i<x; i++) {scanf("%d",&cha);
		if(cha<n && cha>=0)   // Cha >0
		{
			printf("%s %s %s %s %s\n",love[cha].name,love[cha].phone,love[cha].telephone,love[cha].sex,love[cha].year);
		}
		else
		{
				printf("Not Found\n"); }}}Copy the code

138. Calculate how far an object falls (5 points)

An object falls freely from a height of 100 meters. Write a program to find the vertical distance it fell in the first 3 seconds. Let the acceleration of gravity be 10 m/s 2.

Input format: No input for this topic.

Output format: Output in the following format

Height = vertical distance value results keep 2 decimal places.

#include<stdio.h>
int main(a)
{
	int a=10,t=3;
	printf("height = %.2lf\n".0.5*10*t*t);
}
Copy the code

139. Time conversion (15 marks)

In this case, we need to write a program to output the time value of n seconds after a given time in hh:mm:ss format. If the time value exceeds 23:59:59, it starts from 0.

Input format: Enter the start time in hh:mm:ss format in the first line, and the number of whole seconds n (<60) in the second line.

Output format: Output the result time in hh:mm:ss format on one line.

Example: 11:59:4030 Example: 12:00:10

#include<stdio.h>
int main(a)
{
	int h,m,s;
	int n;
	scanf("%d:%d:%d",&h,&m,&s);
	scanf("%d",&n);
	s+=n;
	if(s>=60)
	{
		if(m==59)
		{
			h+=1;
			m=0;
			s-=60;
		}
		else
		{
			m+=1;
			s-=60; }}if(h>=24)
		h-=24;
	printf("%02d:%02d:%02d\n",h,m,s);
}
Copy the code

140. Han Xin Points soldiers (10 points)

In the history of Chinese mathematics, there is a widely spread story of “Han Xin ordered soldiers” : Han Xin was a general under Liu Bang, the Emperor Gaozu of the Han Dynasty. He was brave and skillful in battle, and had superior wisdom and intelligence, which made outstanding contributions to the Han Dynasty. It is said that Han Xin was also very good at mathematics. When he counted his soldiers, in order to know how many soldiers there were and keep military secrets, he asked his soldiers to line up and count them:

Count off from 1 to 5, and write down the last soldier’s count as 1. Count off from 1 to 6, and note that the last soldier gives 5. Count off from 1 to 7, and note that the last soldier gives 4. The last soldier gave ten, counting from one to eleven. Please write a program to calculate at least how many soldiers Han Xin has.

Input format: This topic has no input

Output format: Output the minimum number of soldiers han Xin has.

#include<stdio.h>
int main(a)
{
	int i=1,j;
	while(1)
	{
	  if((i%5= =1)&&(i%6) = =5&&(i%7) = =4&&(i%11) = =10)
	  {
	    printf("%d",i);
	    break;
	  }
	  elsei++; }}Copy the code

Original is not easy, useful please point a praise, thank you!

Creation is not easy, useful please point a thumbs-up, thank you!

141, BCD decryption (10 points)

A BCD number is a two-digit decimal number expressed in one byte, with each four bits representing one digit. So if a BCD number is 0x12 in hexadecimal, it represents 12 in decimal. But Xiaoming did not learn BCD, all BCD numbers as binary numbers converted into decimal output. So BCD 0x12 is printed as decimal 18!

Now, your program will read in the wrong decimal number and output the correct decimal number. Tip: You can convert 18 back to 0x12, and then back to 12.

Input format: Input gives A positive integer in the range of [0, 153] in A line that is guaranteed to be converted back to A valid BCD number, that is, the integer is converted to hexadecimal without a-F numbers.

Output format: The corresponding decimal number is displayed.

Input example: 18 Output example: 12

#include<stdio.h>
int main(a)
{
	int n;
	int a[100000],k=0;
	int i,j;
	scanf("%d",&n);
	if(n==0)
	{
	  printf("0");
	  return 0;
	}
	while(n! =0)
	{
		a[k++]=n%16;
		n/=16;
	}
	for(i=k- 1; i>=0; i--)printf("%d",a[i]);
}
Copy the code

142. Number of traps (15 points)

For any natural number N 0, first add the sum of its digits, then multiply the sum by 3 and add 1 to form a new natural number N 1. Then repeat this operation for N 1 to produce a new natural number N 2; … Repeat this operation many times and the result will be a fixed number N k, like falling into a numerical “trap”.

The process by which the input natural numbers fall into the “trap” is given.

Input format: Give a natural number N 0 (N 0 <30000) in one line.

Output format: For N 0 input, output the steps it fell into the trap line by line. The i-th line describes the i-th step in which N falls into the trap, in the format: I :N I (I ≥1). When the natural number N k (k≥1) obtained in one step is the same as that obtained in the previous step N k−1, the output is stopped.

Example Input: 5 Example output: 1:16 2:22 3:13 4:13

#include<stdio.h>
int number(int N);
int main (a){
   int N=0,count=0,now=0,pre=0;
   scanf("%d",&N);
   now = number(N);
    while(1){
        count++;
        printf("%d:%d\n",count,now);
        pre=now;
        now=number(now);
        if(pre==now){
          if(now! =N)// If the final result of this number is equal to N, no output is needed
            printf("%d:%d\n",count+1,now);
            break; }}return 0;
}
int number(int N){
    int add=0,num=N%10;
    if(num==N){
        add=N;
    }else{
        while(N! =0){
        add+=num;
        N/=10;
        num=N%10; }}return add*3+1;
}
Copy the code

143. Simplified Insertion sort (15 points)

In this case, a program is required to insert a given integer into an ordered sequence of integers, so that the resulting sequence is still ordered.

Input format: Input is given a non-negative integer N (<10) on the first line; The second line gives N integers sorted from smallest to largest; The third line gives us an integer X.

Output format: Output a sequence of integers from smallest to largest after X is inserted in one line, followed by a space for each number.

Example Value: 5 1 2 4 5 7 3 Example value: 1 2 3 4 5 7

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int comp(const void* a,const void* b)
{
	return* (int*)a - *(int*)b;
}
int main(a)
{
	int i;
	int a[12];
	int n;
	scanf("%d",&n);
	for(i=0; i<n; i++) {scanf("%d",&a[i]);
	}
	scanf("%d",&a[n]);
	qsort(a,n+1.sizeof(a[0]),comp);
	for(i=0; i<n+1; i++)printf("%d ",a[i]);
}
Copy the code

144. Comparison of Rational Numbers (10 marks)

The problem requires writing a program to compare the size of two rational numbers.

Input format: Input two fractional rational numbers in a row in the format a1/ B1 a2/ B2, where the numerator and denominator are all positive integers within the integer range.

Output format: Output the relationship of two rational numbers in the format of a1/b1 relation a2/ B2 in a line. > indicates greater than, < indicates less than, and = indicates equal to.

Input Example 1:1/2 3/4 Output Example 1:1/2 < 3/4 Input example 2:6/8 3/4 output example 2:6/8 = 3/4

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int a1,b1,a2,b2;
	double sum1,sum2;
	scanf("%d/%d %d/%d",&a1,&b1,&a2,&b2);
	sum1 = a1*1.0/b1;
	sum2 = a2*1.0/b2;
	if(sum1>sum2)
	printf("%d/%d > %d/%d\n",a1,b1,a2,b2);
	else if(sum1 == sum2)
	printf("%d/%d = %d/%d\n",a1,b1,a2,b2);
	else
	printf("%d/%d < %d/%d\n",a1,b1,a2,b2);
}
Copy the code

145, Calculating the wages of employees (15 points)

Given N employees’ information, including name, base salary, variable salary, and expenses, write a program to output each employee’s name and take-home salary in order (take-home salary = base salary + variable salary – expenses).

Input format: Input is given a positive integer N on a single line. Then N lines, each line gives the information of an employee, in the format of “name basic salary floating salary expenditure”, separated by a space. Name is a non-empty string with less than 10 characters and does not contain whitespace. The input and output of other characters must be within the single precision range.

Output format: according to the input order, each line output one employee’s name and real salary, one space apart, salary reserved 2 decimal places.

3 Zhao 240 400 75 Qian 360 120 50 zhou 560 150 80 Example: Zhao 565.00 QIAN 430.00 zhou 630.00

#include<stdio.h>
#define N 1000
struct yuan
{
  char name[11];
  double z1;// If int is used here, an error is displayed
  double z2;
  double z3;
  double sum
}ren[N];
int main(a)
{
  int n,i;
  scanf("%d",&n);
  for(i=0; i<n; i++) {scanf("%s %lf %lf %lf",ren[i].name,&ren[i].z1,&ren[i].z2,&ren[i].z3);
    ren[i].sum=ren[i].z1+ren[i].z2-ren[i].z3;
  }
  for(i=0; i<n; i++) {printf("%s %.2lf\n",ren[i].name,ren[i].sum);
  }
  return 0;
}
Copy the code

146. The Monkey chooses the King (20 points)

A group of monkeys have to choose a new Monkey King. The new Monkey King was selected by placing N candidates in a circle and numbering them from 1 to N from a certain position. Count off from number 1, report 3 from 1 in each round, the monkey that reports 3 drops out of the circle, and then start the same count from the next monkey next to it. This cycle continues until the last monkey is chosen as the Monkey King. Which monkey was elected Monkey King?

Input format: Input is given a positive integer N (≤1000) in a line.

Output format: Output the number of the selected Monkey King in one line.

Input example: 11 Output example: 7

#include<stdio.h>
int sum=0,i;
int funtion(int x,int y)	//x = 11, y = 3
{
	for(i=y- 1; i<=x; i++)// According to mathematical laws, the special number -1 should be reported from the initial value of I =
	{						// Every time a multiple of 3 is reached, sum=0 and then recalculate
		sum = (sum+3)%i;	//sum+ special % I
	}
	return sum;
}
int main(a)
{
	int i,n,sum=0;
	scanf("%d",&n);
	printf("%d",funtion(n,3) +1);
}
Copy the code

147. Three digits in reverse order (10 points)

The program reads one positive three-digit number at a time, then outputs the digits in reverse order. Note: When the input number contains a trailing 0, the output should not have a leading 0. If you put in 700, the output should be 7.

Input format: Each test is a 3 – digit positive integer.

Output format: Output the number in reverse order by bit.

Example Value: 123 Example value: 321

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int n;
	int i,j;
	int a[3];
	int flag=- 1;
	scanf("%d",&n);
	for(i=0; i<3; i++) { a[i]=n%10;
		n/=10;
	}
	for(i=0; i<3; i++) {if(a[i]! =0)
			flag=1;
		if(flag! =- 1)
		{
			printf("%d",a[i]);
		}
		else if(a[i]! =0)
		{
			printf("%d",a[i]); }}}Copy the code

148. Scoring Rules (5 points)

Xiao Ming played with his friends and invited five judges. Each judge gives a point for each child’s performance. The total score is calculated as follows: the highest score is removed, the lowest score is removed, and the remaining score is averaged as the total score. Please help Xiaoming write a program to calculate the total score.

Input format: Five integers between 0 and 100 are given in a line, separated by a space. The five integers have been sorted in descending order.

Output format: Output the total score in a single line with two decimal places reserved.

Example Value: 100 99 98 97 96 Example value: 98.00

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int comp(const void*a ,const void*b)
{
	return* (int*)a - *(int*)b;
}
int main(a)
{
	int a[5];
	int i,j;
	for(i=0; i<5; i++) {scanf("%d",&a[i]);
	}
	qsort(a,5.sizeof(a[0]),comp);
	a[0] =0;
	a[4] =0;
	double avg = (a[1]+a[2]+a[3) /3;
	printf("%.2lf\n",avg);
}
Copy the code

149. Judges score (5 points)

There’s going to be a quiz in class! The students all participated enthusiastically. Enter the final is 10 students, along with a series of questions, sometimes is the number 1 score, sometimes is the number 5 score, each time the correct answer gets 10 points, the final result?

Input format: The first line has ten integers representing the initial score of ten students. In the second line, an integer n indicates that there are n competitions. Then there are n rows, each of which is marked with a number x, which indicates the number of contestants who are awarded extra points (10 points for each correct answer).

Output format: 10 final scores of students, with a space between each two students.

Example value: 10 0 0 0 10 10 0 0 0 10 3 1 10 1 Example value: 30 0 0 0 10 10 0 0 0 20

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	int i,j;
	int a[10];
	for(i=0; i<10; i++)scanf("%d",&a[i]);
	int n;
	int b;
	scanf("%d",&n);
	for(i=0; i<n; i++) {scanf("%d",&b);
		a[b- 1] + =10;
	}
	for(i=0; i<10; i++) {if(i==10- 1)
		printf("%d",a[i]);
		else
		printf("%d ",a[i]); }}Copy the code

150, Sum of Special A Series (20 marks)

Given two positive integers A and n, neither of which is greater than 9, write a program to find the sum of a+aa+ AA ++… +aa… a (n as).

Input format: Input gives positive integers A and N up to 9 on one line.

Output format: Output in a line in the format of “s = corresponding and”.

Example Value: 2 3 Example value: s = 246

#include<stdio.h>
#include<math.h>
int main(a)
{
	int a,n;
	scanf("%d%d",&a,&n);
	int i,j;
	int t=a;
	int sum=a;
	for(i=1; i<n; i++) { t = a*(pow(10,i))+t;
			//printf("%d\n",t);
			sum+=t;
	}
	printf("s = %d\n",sum);
}
Copy the code

151. Change coins (20 cents)

How many different ways can you change a small amount of change into 5, 2, and 1 cent coins?

Input format: Input gives the amount of change to be changed x∈(8,100) in one line.

Output format: according to the number of 5 cents, 2 cents and 1 cents coins in order from the largest to the smallest, the output of various changes. Each line displays a change method in the format of “FEN5: number of coins of 5 cents, fen2: number of coins of 2 cents, FEN1: number of coins of 1 cent, total: total number of coins”. The last line outputs “count = number of conversions”.

Input example: 13 Output example: fen5:2, fen2:1, fen1:1, total:4 fen5:1, fen2:3, fen1:2, total:6 fen5:1, fen2:2, fen1:4, total:7 fen5:1, fen2:1, fen1:6, total:8 count = 4

#include<stdio.h>
#include<math.h>
int main(a)
{
	int i,j,k;
	int n;
	int t=0;
	scanf("%d",&n);
	for(i=n/5; i>=1; i--) {for(j=n/2; j>=1; j--) {for(k=n; k>=1; k--) {if(i*5+j*2+k==n)
				{
					t++;
					printf("fen5:%d, fen2:%d, fen1:%d, total:%d\n",i,j,k,i+j+k); }}}}printf("count = %d\n",t);
}
Copy the code

152. Drop Ball (20 points)

The ball drops freely from a given height, hits the ground and bounces half of its original height, falls again, and bounces again… “And so on. How far does the ball travel in the air on its NTH landing? What is the height of the NTH bounce?

Input format: Input gives two non-negative integers in a line, the initial height of the ball and n, both in the long integer range.

Output format: Output the distance the ball passes in the air when it lands for the NTH time and the height of the rebound for the NTH time in a sequence on a line, separated by a space with a decimal place reserved. They guarantee that the result is within the range of double precision.

Example Value: 33 5 Example value: 94.9 1.0

#include<stdio.h>
int main(a)
{
	double m;	// Initial height
	int n;	// The height of the NTH bounce
	scanf("%lf%d",&m,&n);
	double sum=m;
	if(m==0 || n==0)
	{
	  printf("0.0 0.0 \ n");
	  return 0;
	}
	for(int i=2; i<=n; i++) { sum+=m; m/=2;
	//	printf("m = %lf sum = %lf\n",m,sum);
	}
	m/=2;
	printf("%.1lf %.1lf\n",sum,m);
}
Copy the code

153, Output student scores (20 points)

This question requires the preparation of procedures, according to the input students’ results, statistics and output students’ average results, the highest results and the lowest results. Dynamic memory allocation is recommended.

Input format: Input the first line first gives a positive integer N, indicating the number of students. The next line gives the scores of N students, separated by Spaces.

Output format: Output in the following format:

Average = average score Max = highest score min = lowest score Results keep two decimal places.

Example: 3 85 90 95 Example: Average = 90.00 Max = 95.00 min = 85.00

#include <stdio.h>
#include <stdlib.h>
 
int main(a)
{	
    int n,i;
    int *p; 
    float sMax,sMin,sSum =0;
    float sAvg;
    scanf("%d",&n); 
	// Enable the length of n int bytes
    p = (int *)malloc(sizeof(int) * n);
    for(i=0; i<n; i++) {scanf("%d",p+i);
    	// If it is the first element, the first element is assigned to both the maximum and minimum values
    	if(i == 0)
    	{
    		sMax = *(p+i);
    		sMin =  *(p+i);	
        }else
	    {
	    	if( *(p+i) > sMax)
	       		sMax =  *(p+i);
		    if( *(p+i) < sMin)
	        	sMin =  *(p+i);
	    }
	    sSum +=  *(p+i);
    }
	printf("average = %.2lf\n",sSum/n);
	printf("max = %.2lf\n",sMax);
	printf("min = %.2lf\n",sMin);
}
Copy the code

154, Find the number of digits and the sum of the digits (15 marks)

For a given positive integer N, find the sum of its bits and its digits.

Input format: Input is given a positive integer N up to 10 9 in a line.

Output format: Output the number of digits of N and the sum of each digit in a line separated by a space.

Example Input: 321 Example output: 3 6

#include<stdio.h>
#include<math.h>

int main(a)
{
	int n;
	int k=0;
	int sum=0;
	scanf("%d",&n);
	while(n! =0)
	{
		sum+=n%10;
		n/=10;
		k++;
	}
	printf("%d %d\n",k,sum);
}
Copy the code

155, The simplest fraction (15 marks)

Fractions can be expressed as numerator/denominator. Write a program that asks the user to enter a fraction and then reduce it into the simplest fraction. The simplest fraction is when there are no divisible elements in the numerator and denominator. For example, 6/12 can be reduced into 1/2. When the numerator is greater than the denominator, you don’t have to express it as an integer and a fraction, 11/8 or 11/8; And when the numerator and denominator are the same, it’s still expressed as a fraction of 1 over 1.

Input format: The input gives a fraction in a line separated by a slash (/). For example, 12/34 indicates 12 over 34. Both the numerator and denominator are positive integers (excluding 0, if the definition of a positive integer is unclear).

Tip: Add/to scanf’s format string and let scanf handle the slash.

Output format: The simplest fraction corresponding to this fraction is printed in one line in the same format as the input, that is, the fraction is expressed as the numerator/denominator. If 5/6 means 5/6.

Example Input: 66/120 Example output: 11/20

#include<stdio.h>
int gcd(int a,int b){
    /*if(a 
    int r=a%b;
    while(r){
        a=b;
        b=r;
        r=a%b;
    } 
    return b;
}
int main(a){
    int a,b;
    scanf("%d/%d",&a,&b);
    int n=gcd(a,b);
    printf("%d/%d",a/n,b/n);
} 
Copy the code

156. I am the Flag Raiser (10 points)

The annual flag-raiser selection is coming again, and the school requires each class to choose one student to be the candidate for flag-raiser. As flag-raisers have strict height requirements, the head teacher decides to choose the tallest student in the class (if two students are of the same height, either one is chosen). Can you give the teacher a quick answer?

Input format: Input consists of two lines. Line 1: contains an integer n, indicating that there are n students in the class. The second row: contains n three-digit numbers, indicating the height of each student.

Output format: Output the height of the tallest student.

Input example: 4 130 125 129 140 Output example: 140

#include<stdio.h>
#include<math.h>

int main(a)
{
	int max=0;
	int n;
	int x;
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {scanf("%d",&x);
		if(max<x)
			max=x;
	 } 
	 printf("%d\n",max);
}
Copy the code

157. RMB exchange (15 marks)

A: One yuan fifty fen yuan for five cent, two cent and one cent coins (each of them). There are 100 of them. There are many ways to change them. Please write programs to give various exchange schemes.

Input format: The input is a positive integer N, indicating the first n possible solutions required for output. The scheme is arranged in order of the five cent coin from lowest to most.

Output format: display the number of coins of 5 cents, 2 cents and 1 cents in the first N schemes. Each line shows a scheme, with one space between the numbers and no space after the last number.

Note: If there are less than n possible alternatives, all possible alternatives are printed sequentially.

Example Value: 5 Example value: 1 46 53 2 42 56 3 38 59 4 34 62 5 30 65

#include<stdio.h>
int main(a)
{
	int i,j,k;
	int wu,er,san;
	int n;
	int t=0;
	scanf("%d",&n);
	for(i=1; i<=150/5; i++)// 1 for 5 points, 30 for 150 points
	{
		for(j=1; j<=150/2; j++)// 1 for 2 points, 75 for 150 points
		{
			for(k=1; k<=100; k++)// Since there can be no more than 100 coins, there can be no more than 100 pennies
			{
				if(i*5+j*2+k==150 && i+j+k==100 && t<n)	// It says output n possible solutions, so input n is ok
				{
					printf("%d %d %d\n",i,j,k);
					t++;	// For each option, +1, up to n options
				}
			}
		}
	}
}
Copy the code

158. Median of two ordered sequences (25 points)

Given that there are two non-descending sequences S1 and S2 of equal length, a function is designed to find the median of the union of S1 and S2. The median of the ordered sequence A 0,A 1… A N−1 refers to the value of A (N−1)/2, that is, the number ⌊(N+1)/2⌋ (A 0 is the first number).

Input format: Input is divided into three lines. The first line gives the common length of the sequence, N (0

Output format: Outputs the median of the union sequence of two input sequences in a single line.

Example 1: 5 1 3 5 7 9 2 3 4 5 6 Example 1: 4 Example 2: 6-100-10 1 1 1 1-50 0 2 3 4 5 Example 2: 1

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int comp(const void* a,const void* b)
{
	return* (int*)b - *(int*)a;
}
int main(a)
{
	int i;
	int n;
	int a[1000001];
	scanf("%d",&n);
	for(i=0; i<n*2; i++) {scanf("%d",&a[i]);
	}
	qsort(a,n*2.sizeof(a[0]),comp);
	printf("%d\n",a[n]);
	return 0;
}
Copy the code

159. Find the student with the highest total score (15 points)

Given the basic information of N students, including the student number (a string of five digits), name (a non-empty string of less than 10 characters without whitespace), and the grades of the three courses (integers in the [0,100] range), ask for the name, student number, and total score of the student with the highest total score.

Input format: Input is given a positive integer N (≤10) on a single line. Then N lines, each line gives a student’s information, in the format of “student number, name, grade 1, grade 2, grade 3”, separated by Spaces in the middle.

Output format: Output the name, student number and total score of the student with the highest total score in one line, separated by one space. They guarantee that such students are unique.

Example Input: 5 00001 huanglan 78 83 75 00002 wanghai 76 80 77 00003 shenqiang 87 83 76 10001 zhangfeng 92 88 78 21987 zhangmeng 80 82 75 Example output: Zhangfeng 10001 258

#include<stdio.h>
struct Student{
	char xuehao[7];
	char name[12];
	int sum;
}love[100];
int comp(const void* a,const void* b)
{
	struct Student *aa = (struct Student *)a;
	struct Student *bb = (struct Student *)b;
	
	return ((bb->sum) - (aa->sum));	// Sort the student information base according to the total score
}
int main(a)
{
	int i,j;
	int n;
	int one,two,three;
	scanf("%d",&n);
	getchar();
	for(i=0; i<n; i++) {scanf("%s%s%d%d%d",&love[i].xuehao,&love[i].name,&one,&two,&three);
		love[i].sum = one+two+three;	// Save the total score
	}
	qsort(love,n,sizeof(love[0]),comp);
	printf("%s %s %d\n",love[0].name,love[0].xuehao,love[0].sum);
}
Copy the code

160. Finding the Partial Sum of Simple Staggered Sequences with Given Precision (15 marks)

In this case, we need to write a program to calculate the sequence part and 1-1/4 + 1/7-1/10 +… Until the absolute value of the last term is not greater than the given precision EPS.

Input format: The input gives a positive real number EPS in one line.

Output format: Print the value S of the partial sum in the format “sum = S” to six decimal places on a single line. They guarantee that the result is within the range of double precision.

Input example 1: 4E-2 Output example 1: sum = 0.854457 Input example 2: 0.02 Output example 2: sum = 0.826310

#include<stdio.h>
int main(a)
{
	int i=0,j;		/ / loop
	int flag = 1;	// Control even digits positive and odd digits negative
	int zi=1,mu=1;
	double a,b,sum=0;
	scanf("%lf",&a);
	do
	{
		b = zi*1.0/mu;	// We need to pay attention to irrational numbers here, so we need to use float, *1.0
		sum+=b*flag;	// The sequence is summed over each loop until the sequence value b<=a breaks out of the loop
		flag=-flag;		// Negative = negative, negative = positive
		mu+=3;			// The numerator is the same, and the denominator is 3 more each time
	}while(b>a);		// No greater than means: neither equal nor small
	printf("sum = %lf\n",sum);
}
Copy the code

Creation is not easy, useful please point a thumbs-up, thank you!

Original is not easy, useful please point a praise, thank you!

161. Length of Words (15 marks)

Your program reads a line of text separated by Spaces into several words. The end. You want to output the length of each word. The words here are independent of language and can include various symbols, such as “It’s”, which counts as a word with length of 4. Note that successive Spaces may appear in the line; The last one doesn’t count.

Input format: Input gives a line of text in a line to. The end of the

Tip: use scanf(“%c”,…) ; To read a character until it reads. So far.

Output format: Print the length of the corresponding words in a line, separated by Spaces, with no final space at the end of the line.

Input example: It’s great to see you here. Example Output: 4 5 2 3 3 4

#include<stdio.h>
int main(a)
{
  /* If there is only one word, there should be no extra space at the beginning and no extra space at the end. 2. The second is not to display 3 when the number of times is 0. The third is to pay attention to the space can not be redundant, no matter the beginning, end, or middle */
	char c;
	int flag=1;   // Control the printing of Spaces
	int k=0;
	scanf("%c",&c);
	while(c! ='. ')   // If there is only one dot, there is no need to display it
	{
		if(c ==' ')
		{
			if(k! =0)
			{
				if(flag)
				{
					printf("%d",k);
					flag=0; // After the first word is printed, you can print it as %d with no space at the end
				}
				else      
				{
					printf(" %d",k);
				}
				k=0; }}else
		{	k++;	}
		scanf("%c",&c);
	}
	if(k! =0)        // Do not print if the last word is a space
	{
		if(flag)      // Be responsible for preventing extra Spaces at the beginning and end
		{
			printf("%d",k);
		}
		else
		{
			printf(" %d",k); }}}Copy the code

162. Table Output (5 marks)

This requires writing a program to output a table in a specified format.

Input format: No input for this topic.

Output format: The following tables are required to be output in strict accordance with the given format:

Province Area(km2) Pop.(10K)

Anhui 139600.00 6461.00

Beijing 16410.54 1180.70

Chongqing 82400.00 3144.23

Shanghai 6340.50 1360.26

Zhejiang 101800.00 4894.00

#include<stdio.h>
int main(a)
{
printf("------------------------------------\n");
printf("Province Area(km2) Pop.(10K)\n");
printf("------------------------------------\n");
printf("Anhui 139600.00 6461.00 \ n");
printf("Beijing 16410.54 1180.70 \ n");
printf("Chongqing 82400.00 3144.23 \ n");
printf("Shanghai 6340.50 1360.26 \ n");
printf("Zhejiang 101800.00 4894.00 \ n");
printf("------------------------------------\n");
}
Copy the code

163. Packing Problems (20 points)

Input format: input the first line to give the number of items N (≤1000); The second line gives N positive integers s I (1≤s I ≤100, representing the size of item I).

Output format: output the size of each item and its box serial number in input order, each item occupies 1 line, and the last line outputs the number of boxes required.

Example Value: 8 60 70 80 90 30 40 10 20 Example value: 60 1 70 2 80 3 90 4 30 1 40 5 10 1 20 2 5

#include<stdio.h>
#include<string.h>
struct Love{
	int xiang;
	int ji;
}love[1001];
int main(a)
{
	int b[1000] = {100};
	int max=0;
	int i,j;
	int first;
	int n;
	int num=0;
	int k=0;
	int a[100],one=0;
	scanf("%d",&n);
	for(i=0; i<n; i++) {scanf("%d",&love[i].xiang);
	}
	for(i=0; i<n; i++) b[i]=100;
	for(i=0; i<n; i++) {for(j=0; j<n; j++) {if(love[i].xiang<=b[j])
			{
				love[i].ji = j;	
				b[j]-=love[i].xiang;
				if(max<j)
					max=j;
				break; }}}for(i=0; i<n; i++) {printf("%d %d\n",love[i].xiang,love[i].ji+1);
	}
	printf("%d\n",max+1);
}
Copy the code

Find the first N terms of staggered sequence and (15 marks)

In this case, we need to write a program to calculate the staggered sequence 1-2/3+3/5-4/7+5/9-6/11+… Sum of the first N terms of phi.

Input format: Input is given a positive integer N in a line.

Output format: Prints the values of partial sums in one line, with three decimal places reserved.

Input example: 5 Output example: 0.917 Author: Chen Jianhai Zhejiang University Time limit: 400 MS Memory limit: 64 MB

#include<stdio.h>
int main(a)
{
	int n;
	int i;
	int zi = 1,mu = 1;
	int flag=1;
	double sum=0;
	scanf("%d",&n);
	for(i=0; i<n; i++) { sum+=zi*1.0/mu*flag;
		flag=-flag;
		zi+=1;
		mu+=2;
	}
	printf("%.3lf\n",sum);
}
Copy the code

165. Finding the mean square Deviation of Set Data (15 marks)



Input format:

The input begins by giving a positive integer N (≤10) on the first line

​4

), the next line gives N positive integers. All the digits cannot exceed 1000. Separate the digits in the same row with Spaces.

Output format: output the N numbers of the mean square error, requires fixed precision output 5 decimal places.

Example Value: 10 6 3 7 1 4 8 2 9 11 5 Example value: 3.03974 Example value: 2 2 Example value: 0.00000

#include<stdio.h>
#include<math.h>
int main(a)
{
	int n;
	int i,j;
	double x=0;
	int a[10005];
	double result;
	int sum=0;
	double avg; 
	scanf("%d",&n);
	for(i=0; i<n; i++) {scanf("%d",&a[i]);
		sum+=a[i];
		//printf("1");
	}
	avg = sum*1.0/n;
	for(i=0; i<n; i++) { x += (a[i]-avg)*(a[i]-avg);//printf("2");
	}
	result = sqrt(x/n);
	printf("%.5lf\n",result);	
}
Copy the code

166. Currency conversion (20 cents)

Enter an integer (the number of digits does not exceed 9) to represent a people’s currency (unit: yuan). Please convert it into uppercase Chinese format as required by finance. Such as 23,108 yuan, after conversion into “twenty-three thousand one hundred and eight” yuan. To simplify the output, lowercase letters A-J are used to represent uppercase numbers 0-9, and S, B, Q, W, and Y are used to represent ten, one hundred, ten thousand, ten million, and one hundred million respectively. So 23108 yuan should be converted to output as “cWdQbBai” yuan.

Input format: Input gives a non-negative integer of no more than 9 digits in a line.

Output format: Output the converted result in one line. Note that the usage of “zero” must conform to the Chinese custom.

Input Example 1:813227345 Output Example 1: iYbQdBcScWhQdBeSf Input Example 2:6900 Output example 2: gQjB

I didn’t get it right, I didn’t get a perfect score, like 15, but I want to remember my code

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(a)
{
	int num;
	int i,j,n,xing=0;
	char s[100];
	char str1[100],a=- 1;
	int k=0;		// Count the digits
	int flag=1;
	gets(s);
	int len = strlen(s);
	for(i=0; i<len; i++) { num = s[i]-'0';
		if(num! =0)
		{
			xing++;
			flag=0;
		}
		if(i==len- 1&& num! =0)
			flag=1;
	}
	for(i=0; s[i]! ='\ 0'; i++) { num = s[i]-'0';
		if(s[i]+=2)
		switch(num)
		{
		case 0:str1[++a]='a';break;
		case 1:str1[++a]='b';break;
		case 2:str1[++a]='c';break;
		case 3:str1[++a]='d';break;
		case 4:str1[++a]='e';break;
		case 5:str1[++a]='f';break;
		case 6:str1[++a]='g';break;
		case 7:str1[++a]='h';break;
		case 8:str1[++a]='i';break;
		case 9:str1[++a]='j';break;
		}
		a++;
		k++;
	}
	/*for(i=0; i		/ / debugging
	n=0;
	for(i=k*2- 1; i>=0;)
	{
		if(n==1 || n==5)
		{
			str1[i]='S';
		}
		else if(n==2 || n==6)
		{
			str1[i]='B';
		}
		else if(n==3 || n==7)
		{
			str1[i]='Q';
		}
		else if(n==4)
		{
			str1[i]='W';
		}
		else
		{
			str1[i]='Y';
		}
		
		n++;
		i-=2;
	}
	if(flag)
		for(i=0; i<k+k- 1; i++)printf("%c",str1[i]);
	else
			for(i=0; i<k+k- 1-xing*2+1; i++)printf("%c",str1[i]);
}
Copy the code

167. Finding the Local Maximum of the Matrix (15 marks)

Given an integer matrix A with M rows and N columns, if the non-boundary element A[I][j] of A is larger than four adjacent elements, then element A[I][j] is said to be the local maximum of the matrix. The problem requires all local maxima of a given matrix and their positions.

Input format: input in the first line gives the number of rows M and columns N of matrix A (3≤M,N≤20); And then the last M rows, each row gives the N elements of A in that row. Numbers are separated by Spaces.

Output format: Each line outputs a local maximum value in the format of “element value row number column number”, where the row and column numbers start from 1. Require incrementing output by line number; If there is more than one local maximum in a row, the row is output incremented by column number. If there is no local maximum, “None total number of rows total number of columns” is printed.

Example 1:4 5 1 1 1 3 9 3 1 1 5 3 5 1 1 1 1 1 1 example 1 Output Example 1:9 2 3 5 3 3 2 5 3 4 Example 2: 3 5 1 1 1 9 3 9 9 1 1 5 3 5 1 Example 2: None 3 5

#include<stdio.h>
struct Love{
	int hang;
	int lie;
	int max;
}Max[200];
int main(a)
{
	int m,n;
	int i,j;
	int a[300] [300];
	//int max[20],k=0;
	int k=0;
	int flag=0;
	scanf("%d%d",&m,&n);
	for(i=0; i<m; i++) {for(j=0; j<n; j++) {scanf("%d",&a[i][j]); }}for(i=0; i<m; i++) {if(i==0)
			continue;
		if(i==m- 1)
			break;
		for(j=0; j<n; j++) {if(j==0||j==n- 1)
				continue;
			if(a[i][j]>a[i- 1][j] && a[i][j]>a[i+1][j] && a[i][j]>a[i][j+1] && a[i][j]>a[i][j- 1])
			{
									Max[k].max=a[i][j];
									Max[k].hang=i+1;
									Max[k].lie=j+1;
									k++;
									flag=1; }}}if(flag! =0)
	{
		for(i=0; i<k; i++) {printf("%d %d %d\n",Max[i].max,Max[i].hang,Max[i].lie); }}else
	{
		printf("None %d %d\n",m,n); }}Copy the code

168, Check the price of fruit (15 points)

Given four kinds of fruits, apple, pear, orange and grape, the unit prices are 3.00 yuan/kg, 2.50 yuan/kg, 4.10 yuan/kg and 10.20 yuan/kg respectively.

First display the following menu on the screen:

[1] Apple [2] Pear [3] Orange [4] Grape [0] exit Users can enter numbers 1 to 4 to query the unit price of the fruit. When the number of consecutive queries exceeds 5 times, the program should automatically exit the query; Less than 5 times and the user enters 0 to exit; Enter other numbers to display the price as 0.

Input format: Enter a number of consecutive user input numbers in a row.

Output format: First display the menu on the screen. For each input from the user, the query result is then printed in the format “price = price” on one line, where the price is reserved for two decimal places. When the user queries for more than 5 times or actively enters 0, the program ends.

Example 1: [1] Apple [2] Pear [3] Orange [4] Grape [0] Exit price = 4.10 price = 0.00 Example 2: 1 2 3 3 4 4 5 6 7 8 Example 2: [1] Apple [2] Pear [3] Orange [4] Grape [0] exit price = 3.00 price = 2.50 price = 4.10 price = 4.10 price = 10.20

#include<stdio.h>
int main(a)
{
	int i,j;
	int n;
	int x;
	printf("[1] apple\n");
	printf("[2] pear\n");
	printf("[3] orange\n");
	printf("[4] grape\n");
	printf("[0] exit\n");
	
	for(i=0; i<5; i++) {scanf("%d",&x);
		if(x==0)
		break;
		if(x<0 || x>4)
		printf("Price = 0.00 \ n");
		if(x==1)
		printf("Price = 3.00 \ n");
		else if(x==2)
		printf("Price = 2.50 \ n");
		else if(x==3)
		printf("Price = 4.10 \ n");
		else if(x==4)
		printf("Price = 10.20 \ n"); }}Copy the code

169. Mixed type data Formatting input (5 points)

In this case, you need to write a program to read floating point 1, integer, character, and floating point 2 in sequence, and then output them in the sequence of character, integer, floating point 1, and floating point 2.

Input format: Float 1, integer, character, float 2 are given in sequence on a line, separated by a space.

Output format: The output is in the order of characters, integers, floating-point numbers 1, and floating-point numbers 2 on a single line, where floating-point numbers are reserved for two decimal places.

Example: 2.12 88 C 4.7 Example: C 88 2.12 4.70

#include<stdio.h>
int main(a)
{
	double a;
	int b;
	char c;
	double d;
	scanf("%lf%d %c%lf",&a,&b,&c,&d);
	printf("%c %d %.2lf %.2lf\n",c,b,a,d);
}
Copy the code

170, BCD decryption (10 marks)

A BCD number is a two-digit decimal number expressed in one byte, with each four bits representing one digit. So if a BCD number is 0x12 in hexadecimal, it represents 12 in decimal. But Xiaoming did not learn BCD, all BCD numbers as binary numbers converted into decimal output. So BCD 0x12 is printed as decimal 18!

Now, your program will read in the wrong decimal number and output the correct decimal number. Tip: You can convert 18 back to 0x12, and then back to 12.

Input format: Input gives A positive integer in the range of [0, 153] in A line that is guaranteed to be converted back to A valid BCD number, that is, the integer is converted to hexadecimal without a-F numbers.

Output format: The corresponding decimal number is displayed.

Input example: 18 Output example: 12

#include<stdio.h>
int main(a)
{
	int n;
	int a[100000],k=0;
	int i,j;
	scanf("%d",&n);
	if(n==0)
	{
	  printf("0");
	  return 0;
	}
	while(n! =0)
	{
		a[k++]=n%16;
		n/=16;
	}
	for(i=k- 1; i>=0; i--)printf("%d",a[i]);
}
Copy the code

171. String Pattern Matching (25 points)

Given two alphabetic strings of String and Pattern, find the position where Pattern appears for the first time in the String and print the substring of the String following this position. If Not, “Not Found” is displayed.

This topic aims to test the performance of various matching algorithms in various data cases. The characteristics of test data of each group are as follows:

Data 0: small string, test basic correctness; Data 1: random data. The String length is 10, and the Pattern length is 10. Data 2: random data. The String length is 10 5, and the Pattern length is 10 2. Data 3: random data. The String length is 10 5, and the Pattern length is 10 3. Data 4: random data. The String length is 10 5, and the Pattern length is 10 4. Data 5: The String length is 10 6, and the Pattern length is 10 5. Test the case that the last character does not match; Data 6: The String length is 10 6, and the Pattern length is 10 5. Tests for first character mismatches. Input format: The first line of the input String is a String of up to 10 or 6 English letters. The second line gives a positive integer N (≤10), the number of pattern strings to be matched. The following N lines are displayed. Each line contains a Pattern, which is a string of no more than 10 and 5 English letters. Each string is non-empty and ends with a carriage return.

Output format: For each Pattern, output matching results according to the requirements of the topic.

Example: abcabcabcabcabcacabxy 3 abcabcacab cabcabcd abcabcabcabcabcacabxyz Example: Abcabcacabxy Not Found Not Found

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(a)
{
	char str1[1000001],str2[1000001];
	int i,n;
	gets(str1);
	scanf("%d",&n);
	getchar();
	for(i=0; i<n; i++) { gets(str2);char *p=strstr(str1,str2);
		if(p! =NULL)
		{
			for(; *p! ='\ 0'; p++)printf("%c",*p);
			printf("\n");
		}
		else
			printf("Not Found\n");
	}
	return 0;
}
Copy the code

179, Integers (5 分)

Say hello to integers? Yes! You read that right! Now let’s say “hello ~” to the integers. The question reads two integers and prints out a greeting for them.

Input format: Give two integers A and B with absolute values of up to 32767 on A single line, with A space between them

Output format: Output “Hello, A and B!” in one line. (where A and B are replaced by integers from the actual input)

Example: 1949 2015 Example: Hello, 1949 and 2015!

#include<stdio.h>
int main(void)
{
	int n,m;
	scanf("%d%d",&n,&m);
	printf("Hello, %d and %d! \n",n,m);
}
Copy the code

173. PTA makes me refreshed (5 marks)

PTA refreshed me

The above is the work of hubei College of Economics students. In this case, please use Chinese pinyin output this sentence.

Input format: No input in this topic.

Output format: Output as sample in a line, ending with an exclamation point.

Input example: None Output example: PTA shi3 WO3 jing1 shen2 huan4 FA1!

#include<stdio.h>
int main(a)
{
  printf("PTA shi3 wo3 jing1 shen2 huan4 fa1 ! \n");
  return 0;
}
Copy the code

174. Temperature conversion (5 marks)

In this case, we need to write a program to calculate the Celsius temperature corresponding to 150°F. The calculation formula is as follows: C=5 x (F−32)/9, where C stands for Celsius temperature and F stands for Fahrenheit temperature. The output data must be an integer.

Input format: No input for this topic.

Output format: Output in the following format

Fahr = 150, Celsius = Integer value of the temperature

#include<stdio.h>
int main(a)
{
  int f=150;
  printf("fahr = 150, celsius = %d\n".5*(f- 32) /9);
  return 0;
}
Copy the code

175. Output diamond pattern (5 marks)

This requires writing A program that prints the specified diamond pattern of “A”.

Input format: This topic has no input

Output format: Output the diamond pattern composed of “A” in the following format.

A

A A

A

#include<stdio.h>
int main(a)
{
	printf(" A\n");
	printf("A A\n");
	printf(" A\n");
}
Copy the code

176. Fish or meat (10 points)





The country gave a standard height of 130 centimeters and a standard weight of 27 kilograms for an 8-year-old boy. The standard height for an 8-year-old girl is 129 centimeters and the standard weight is 25 kilograms.

Now you have to give advice on supplementary nutrition according to the baby’s height and weight.

Input format: Input in the first line gives a positive integer N not more than 10, followed by N lines, each line gives a baby’s body data:

Gender Height and weight: 1 for male and 0 for female. Height and weight are positive whole numbers up to 200.

Output format: For each baby, give your advice in one line:

If too short, output: Duo Chi Yu! Eat more fish If too thin, output: Duo Chi Rou! Eat more meat If positive, output: wan Mei! Perfect; If it’s too high, output: ni Li Hai! You’re good. If too fat, output: Shao Chi Rou! Eat less meat. Evaluate height first, then weight. There should be a space between two sentences.

Example: 4 0 130 23 1 129 27 1 130 30 0 128 27 Example: Ni Li Hai! duo chi rou! duo chi yu! wan mei! wan mei! shao chi rou! duo chi yu! shao chi rou!

#include<stdio.h> 
int main(a)
{
	int a,s,h,w;
	scanf("%d",&a);
	while(a--)
	{
		scanf("%d %d %d",&s,&h,&w);
	    switch(s)
	    {
			case 1: 
			if(h==130) printf("wan mei! ");
			else if(h<130) printf("duo chi yu! ");
			else if(h>130) printf("ni li hai! ");
			if(w==27) printf("wan mei! \n");
			else if(w<27) printf("duo chi rou! \n");
			else if(w>27) printf("shao chi rou! \n");
			break;
			case 0:
			if(h==129) printf("wan mei! ");
			else if(h<129) printf("duo chi yu! ");
			else if(h>129) printf("ni li hai! ");
			if(w==25) printf("wan mei! \n");
			else if(w<25) printf("duo chi rou! \n");
			else if(w>25) printf("shao chi rou! \n");
			break; }}return 0;
}
Copy the code

Original is not easy, useful please point a praise, thank you!