Alibabacloud.com offers a wide variety of articles about plc programming exercises, easily find your plc programming exercises information here online.
calculates the tax. Use loops so that users can enter multiple times.#include The ABC Mail Order Grocery Artichoke is priced at $1.25/lb, the beet is priced at $0.65/lb, and the carrot is priced at $0.89/lb. Before adding shipping charges, they offer a 5% discount on orders of $100. Shipping and handling costs of $3.50 are charged for orders of 5 pounds or less, and orders over 5 lbs. and less than 20 lbs. for shipping and handling costs of 1o.oo USD: 20 pounds or more, plus $8 per pound on a $
Reference for programming exercises after Chapter C and pointer -- Chapter 10th and Chapter 10th of Chapter c and pointer
10.1
1 #include
10.2
1 #include
10.3
1 #include
Reference for programming exercises in Chapter C and pointer -- 6.3, c and pointer 6.3
C and pointer -- 6.3
Question:
Write a function to sort the characters in the parameter string in reverse order.
Function prototype:
Void reverse_string (char * string );
Requirements:
Use Pointer instead of array subscript
Do not use any C function library to manipulate strings.
Do not declare a local array to temporaril
Random#产生随机集合Def randomset ():s = Set (")N = Random.randint (1,10)For I in Range (N):S.add (Random.randint (0,9))return sA = Randomset ()B = Randomset ()Print A, b#print a| B,ab# A = set ()# B = set ()# A.add (1)# A.add (2)# B.add (2)# Print a| B,ab#对输入进行处理, go [], Save as Collection#要考虑输入为空集的处理#输入格式为 [], turn into ', then set (')def input_to_set (S1):Set1 = set ()If S1! = ' [] ':U1,U2 = S1.split (' [')U1,U3 = U2.split ('] ')List1 = U1.split (', ')For I in List1:j = Int (i) #列表中单独字符串转换为数字Set1.a
Using system;using system.collections.generic;using system.linq;using system.text;using System.Threading.Tasks; Namespace consoleapplication1{ Class program {public class-Apple {public string info; Public Apple () { } public string app (string[] a) { foreach (string value in a) info + = value + "+"; Info=info. Substring (0,info. LENGTH-1); retur
, and if so, the number of occurrences of the statistic.Practice Code:public class Test {public static void Main (string[] args) {//defines a string s = "Aljlkdsflkjsadjfklhasdkjlflkajdflwoi UDSAFHAASDASD "; Number of occurrences int num = 0; Loop through each character to determine if it is a character a, if yes, the number of increments for (int i=0;iOperation Result: Three outputs the number of characters in a string Function: Write a program that outputs the
can use the pointer's offset or array subscript to manipulate(2)1 Char New CharNote that strlen does not count for empty characters, so there is less space in the heap memory allocation for empty characters, resulting in many functions not stopping reading at the end of this character.1 Char New Char 1Allocate one more, or you can use sizeof (note that sizeof points to the heap memory pointer to the size of the pointer).(3)You might be releasing the array heap memory like this.1 Delete PA; Com
Tag: the sum () function provided by Python can accept a list and sum please write a prod () function to accept a list and use the reduce () to calculate the product:1 #Python提供的sum () function can accept a list and sum, write a prod () function, you can accept a list and use reduce () to calculate the product:Code:2 3 from Functools import reduce 4 Li = [1,2,3,4,5,7] 5 print (sum (LI)) 6 7 def prod (x, y): 8 return x * y 9 Ten R = Reduce (Prod,li) one print (R)Operation Result:[[email protected
Practice 1-7 Writing a program that prints the values of EOF.#include // contains information about the standard library. int main () // defines a function named Main, which does not accept parameter values. { // output EOF. printf ("EOF" corresponds to the number of shapes is%d.) \ n", EOF); Getch (); // Prevent the console from flashing through, you need to accept any characters after you close the console. return0; // returns a shape to the execut
Practice 1-1 running the "Hello, World" program in your own system. Then deliberately remove part of the program, to see what error messages will be obtained.The code is as follows:#include // contains information about the standard library. int main () // defines a function named Main, which does not accept parameter values. { printf ("Hello, world\n"); // The man function calls the library function printf to display a sequence of characters. getch (); // Prevent t
Practice 1-18 Write a program that removes spaces and tabs at the end of each input line and removes rows that are completely blank.The code is as follows:#include //contains information about the standard library. #defineMAXLINE 10//the maximum number of characters per line is 1000. intGetlineCharLine[],intmaxline);intMain ()//defines a function named Main, which does not accept parameter values. { intLen; inti; CharLine[maxline]; while(len = getline (line, MAXLINE)) >0) { intc =
Exercise 1-15 Rewrite the temperature conversion program in section 1.2 and use the function to achieve temperature conversion calculations.The code is as follows:#include //contains information about the standard library. floatFahrtocelsius (floatFahr);floatCelsiustofahr (floatCelsius);intMain ()//defines a function named Main, which does not accept parameter values. {printf ("1 degrees Fahrenheit is equal to%.1f degrees Celsius .", Fahrtocelsius (1)); printf ("\ n"); printf ("1 degrees Celsius
Practice 1-6 Verify that the value of the expression GetChar ()! = EOF is 0 or 1.The code is as follows:#include //contains information about the standard library. intMain ()//defines a function named Main, which does not accept parameter values. { //Verify that the value of GetChar ()! = EOF is 0 or 1. printf"Verify that the value of GetChar ()! = EOF is 0 or 1. \ n"); printf ("the validation is complete and the result is%d. \ n", GetChar ()! =EOF); Getch (); //prevent the console from fl
C Language Student Management system:This program synthesizes the list, sorting and other knowledge, can be said to be a comprehensive exercise.# include Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. Introduction to C language Programming--comprehensive Exercises (iii) Student management system
Exercise 1-22 writes a program that "folds" the longer input lines into shorter two or more lines, after the last non-whitespace before the nth column of the input row. Ensure that the program intelligently handles input lines that are long and that there are no spaces or tabs in front of the columns you have set.The code is as follows:#include //contains information about the standard library. #defineMAXLINE 1000//the maximum number of characters per line is 1000. #defineBR 10//10 characters in
; for(i =0; I 1 (c = GetChar ())! = EOF c! ='\ n';) { if(c = ='\ t') { //If you enter a tab, the following algorithm is used to calculate how many spaces are required to fill. intj =0; J= detab-i%Detab; while(J >0) {s[i++] =' '; J--; } } Else if(c = ='\ n') {s[i++] =C; } Elses[i++] =C; } S[i]=' /'; returni;}Personal Understanding:Apply n as a symbolic constant to the global benefit of uniform modification of the program, with the number of sp
Exercise 1-19 writes the function reverse (s), reversing the order of characters in the string s. Use this function to write a program that reverses the order of characters in one input line at a time.The code is as follows:#include //contains information about the standard library. #defineMAXLINE 10//the maximum number of characters per line is 1000. intGetlineCharLine[],intmaxline);voidReverseCharLine[],intlen);intMain ()//defines a function named Main, which does not accept parameter values.
60, the loop performs the add-on operation and counts the number of points - - - + - + A at //print output plus score, plus number of points - - - - - } in}1 Public classHelloWorld {2 Public Static voidMain (string[] args) {3 4 //Variable Save score5 intScore = 53; 6 7 //variables are saved in addition to the number of times8 intCount = 0;9 Ten One
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.