Want to know c# programming exercises with solutions? we have a huge selection of c# programming exercises with solutions information on alibabacloud.com
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.
virtual number-(void) print; // print the result-(double) Real;-(double) imaginary; @ end // -------------- implementation section ---------------- @ implementation Complex {double real; double imaginary;}-(void) setreal: (double) A {real = A;}-(void) setimaginary: (double) B {imaginary = B;}-(void) print {nslog (@ "the complex is %. F + %. fi ", real, imaginary);}-(double) Real {return real;}-(double) imaginary {return imaginary ;} @ end // ---------------- program section ------------- int ma
#include using namespacestd;intMain () {intA,b,c; cout"Please enter a number of three integer types:"Endl; CIN>>a>>b>>C; voidSortintXintYintz); Sort (a,b,c);//ABC has a specific value, called the actual parameter return 0;} voidSortintXintYintZ//used to receive actual parameters, called formal parameters{ inttemp; if(x>y) {temp=x;x=y;y=temp; } if(zx) cou
#include using namespacestd;intMain () {intA,b,c; intFintXintYintZ);//this is the declaration of the function//CIN Sonsole Consolecout"Please enter a number of three integer types:"Endl; CIN>>a>>b>>B; C=f (A,B,C);//ABC has a specific value, called the actual parametercoutEndl; return 0;}intFintXintYintZ//used to receive actual parameters, called formal parameters
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. }Personal Understanding:The purpose of the exercise is to master the use of the For loop.In the actual programming process, you can choose the while and for any one of the loop statements, mainly depends on which kind of gengqing hi.The For statement is more
At this point, the basic knowledge of C language has been basically finished, but you will find that the C language, but you can not do anything, when I learned here is also the case, learning programming is a long process, the front is just the foundation of programming language, there will be a long way to go, and ho
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
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
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
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
, and copy len non-null characters to the DST array up to a maximum. After the copy is complete, the DST array must end with a null byteThe return value of the function is the length of the string stored in the DST array.If the position specified by start crosses the tail of the SRC array, or the value of start or Len is negative, then the copy to the DST array is an empty string. #include 7. Write a function to remove the extra spaces from a string. Function Prototypes:void Deblank (char string
C # object-oriented programming exercises,
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) info + = value + "+"; info = info.
);intMain () {using namespacestd; DoubleLight_years; cout"Enter the number of light years:"; CIN>>Light_years; Cin.Get(); cout"Light years =""Astronomical Units"; Cin.Get();}DoubleConvertDoublelight_years) { DoubleUnits = Light_years *63240; returnunits;}2.7.7#include voidTimerint,int);intMain () {using namespacestd; inthours, minutes; cout"Enter the number of hours:"; CIN>>hours; cout"Enter the number of minutes:"; CIN>>minutes; Cin.Get(); Timer (hours, minutes); Cin.Get();}voidTimerintHo
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(
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
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.