program to test the function.#include 5. Write a function. The visit function accepts the following parameters: the name of an int array, the size of an array, and a value that represents the number of picks. The function then randomly selects the specified number of elements from the array and prints them. Each element is selected at most once (draw or select a jury member). Also, if your implementation supports time () (described in the 12th chapter) or other similar functions, the output of
: function 1, achieve the sum of two values given, function 2, take the greatest common divisor of the given two values, function 3, take the least common multiple of the given two numeric values, and the size of the selected and two numeric values of the function will be provided through interactive input. Note: Really do not know the number of conventions, common multiple, copy of the Chino students homework#!/bin/bash#if [[$1-eq] "]];thenecho ' plz input the first number ' exit 1fiif [[$2-eq]
answer to its calling function.#include 13. The following is a two function prototype:void Show (double ar[], int n); n is the number of elementsvoid Show2 (double ar2[][3], int n); n is the number of rowsA, write a function call to pass the compound text containing the values 8, 3, 9, and 2 to the function shows ().b, write a function call to pass a compound literal containing 2 rows and 3 columns of value to the function Show2 (), where the first behavior is 8, 3, 9, and the second behavior i
Topic One: Summation exercise:#!/bin/bashfunction Sumarray {Local sum=0Local arrayArray= (echo "[emailprotected]")For value in ${array[]}Dosum=$[$sum + $value]DoneEcho $sum}Wang= (1 2 3 4 5)echo "Initial data is: ${wang[]}"Kai=echo ${wang[*]}result=sumarray $kaiecho "result is: $result"Exit 0Analysis: In this topic I pay attention to the practice of the definition and use of functions, as well as the use of arrays, these are the key points of the shell progr
-*-defcalc_sum ():Globalsum sum=0 I=0 whileI : Num= Int (Raw_input ("Please enter five numbers in turn:". Decode ("Utf-8"). Encode ("GBK")) sum= Sum +num I+ = 1returnsum whileTrue:choice= Raw_input ("1 Summing, 2 averaging, x exit, please enter your choice:". Decode ("Utf-8"). Encode ("GBK")) ifChoice = ='X': PrintU"program will exit" Break elifChoice.isdigit () andint (choice) = = 1:#isdigit () is used to determine whether an object is a number, which is a number that retur
. Bank interest. Write a function that takes the term deposit interest rate as a parameter, assuming that the account calculates compound interest on a daily basis, calculate and return the annual return.#工商银行定期存日款率0.35%def interest_year_return (capital, rates): #capital is the principal, rate is the dayCapital_ori = Capitali = 1While True:Capital = Capital * (1+rate) # capital = Capital * ((1+rate) **365)i + = 1if i = = 366:BreakReturn ((Capital-capital_ori)/capital_ori)#print (Interest_year_re
. for(row =0; Row ) { if(GetLength (Cs[row]) >Ten) {printf ("%s\n", Cs[row]); }} getchar (); //prevent the console from flashing through, you need to accept any characters after you close the console. return 0;//returns a shape to the execution environment, and 0 represents a successful execution. }//gets the length of each line. intGetLength (Charcs[]) { inti =0; while(cs[i++]! =' /') ; returni;}Personal Understanding:Limit the maximum number of rows to support 10 line
Practice 1-8 Write a program that counts the number of spaces, tabs, and line breaks.The code is as follows:#include //contains information about the standard library. intMain ()//defines a function named Main, which does not accept parameter values. {printf ("====== counts the number of spaces, tabs, and line breaks in the characters entered ======\n"); //characters entered, space-space Counter, tab counter, line break counter. intC, SL, TL, NL; SL= TL = NL =0; while((c = GetChar ())! =EOF
Practice 1-9 Write a program that copies the input to the output and replaces it with a single space in a contiguous number of spaces.The code is as follows:#include //contains information about the standard library. intMain ()//defines a function named Main, which does not accept parameter values. {printf ("====== will enter multiple spaces with a single space instead of ======\n"); intC, Space; while((c = GetChar ())! =EOF) { if(c! =' ') Putchar (c);//If the character entered is not a
1.[error]ld returned 1 exit statusEnvironment: Dev C + +Cause: Didn't turn off the last running window, just turn it off.(There are other reasons on the Internet, such as to meet the record again.) )2. Resolve this function or variable could be unsafeEnvironment: vs2015Cause: Some of the unsafe functions in C + + are not compatible.Workaround: Add _crt_secure_no_warnings in the c/c++--preprocessor for the project properties."Programming
Java. util. arraylist; import Java. util. random;/** train of thought * between 1-30 ---> XXX. nextint (30) + 1; * All even elements ---> if (I % 2 = 0) {even number} * method public static string method (arraylist At the beginning of the game, an integer number ranging from 1 to is randomly generated. The player guesses a number guessnumber, which will compare with the number. The system prompts that the number is large or small until the player guesses it and the game ends.
Package random;/*
1. invalid: 6_05 (cannot begin with a number)
A $ ($ is an invalid symbol ).
2. mybook (openbook, closebook, readbook, takebook, putbook ).
3. [mybook takebook];
[Mybook openbook];
[Mybook readbook];
[Mybook closebook];
[Mybook putbook];
4. [myboat driver];
[Mymotorcycle driver];
[Mycar driver];
Overlap.
5. Ease and reduce the memory (I understand that the question is not too clear ).
6. Understand the advantages and disadvantages of Procedural language and object-oriented language.
7.
// ------
Practice 1-14 Write a program that prints a histogram of the frequency of each character in the input.The code is as follows:#include //contains information about the standard library. intMain ()//defines a function named Main, which does not accept parameter values. {printf ("====== The histogram of the frequency of the input characters printed ======\n"); unsignedintXst -];//an array of character frequencies. intI, J, C; I= J = c =0; //The default occurs 0 times per character. for(i =
Practice 1-16 Modify the main program of the program that prints the longest line of text, main, so that it can print the length of any length of input lines and print as much text as possible.The code is as follows:#include //contains information about the standard library. #defineMAXLINE 10intGetlineCharLine[],intmaxline);intMain ()//defines a function named Main, which does not accept parameter values. { intLen; intMax; CharLine[maxline]; while(max = Getline (line, MAXLINE)) >0) {printf (
replaced immediately, and the input is not copied to the output program. /*while ((c = getch ())! =) {if (c = = ' \ t ') printf ("\\t"); else if (c = = ' \b ') printf ("\\b"); else if (c = = ' \ \ ') printf ("\\\\"); else Putchar (c); }*/ //Getch (); //prevent the console from flashing through, you need to accept any characters after you close the console. //return 0; //returns a shape to the execution environment, and 0 represents a successful execution. //This topi
Practice 1-11 How are you going to test the word count program? If there is some kind of error in the program, what kind of input is most likely to find such errors?The code is as follows:#include //contains information about the standard library. #defineIn 1/* within the word */#defineOut 0/* outside the word */intMainvoid)//defines a function named Main, which does not accept parameter values. {printf ("====== counter Program ======\n"); intC, NL, NW, NC, State; State=Out ; NL= NW = NC =0; wh
Linux C Programming series exercises system call file IO, memory ing program write ls program, the system calls ls
Click Connect to enter the article
1.1Linux System Call exercise
1.2 simulate Linux ls program to display the tree directory
1.3 Memory sharing for simple data sharing
Linux C development is not a matter of two or three days. You need to start from the basics and write a blog to record
in daily life and do your best to help others. I hope that my own actions will be recognized and appreciated by others.
Enfj
Enthusiastic, considerate for others, easy to sense, and responsible. Focus on others' feelings, needs, and motivations. Be good at discovering the potential of others and hope to help them achieve it. Can become a catalyst for personal or group growth and progress. Loyal, will actively respond to praise and criticism. Friendly and social networking. Helping others
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.