OpenJudge exercises (C ++) -- question 4074: Water AccumulationQuestion:
Total time limit: 1000 ms memory limit: 65536kB
Description
The uneven ground always accumulates water when it rains. Assume that the ground is one-dimensional, each piece of width is 1, and the height is a non-negative integer, you can use an array to express a piece of ground. For example, [,] can be used to repr
OpenJudge exercises (C ++) -- question 4040: Book PurchasingQuestion:
Total time limit:
1000 ms
Memory limit:
65536kB
Description
An online bookstore offers two discount strategies. Policy 1: free shipping is available if the total amount of books purchased exceeds 100 yuan. Policy 2: If the number of books to be bought is greater than 3, the total amount o
/*Write a function whose function is to reverse the input string. In a complete application that uses a looping statement to provide input for this functionTest in the program.*/#include #include void Fanxu (char *zf); Inverse order functionint main (void){Char a[80];Do{Gets (a);Fanxu (a);printf ("Whether to continue (y/n):");Gets (a);} while (*a! = ' n ');return 0;}/*//Method One:void Fanxu (char *zf){Char *pc;PC = ZF;while (*++PC){Continue}pc--;while (PC >= ZF){Putchar (*PC);pc--;}Putchar (' \
Number of characters in the statistics file (with command line arguments)#include #include int main (int argc, char *argv[]){Char ch;FILE *FP;Long count=0;if (argc!=2){printf ("File name is:%s\n", argv[0]);Exit (Exit_failure);}if ((Fp=fopen (argv[1], "r+") ==null){fprintf (stderr, "Cannot open file \"%s\ "\ n", argv[1]);Exit (Exit_failure);}while ((CH=GETC (FP))!=eof){PUTC (ch,stdout);++count;}Fclose (FP);printf ("File%s has%ld characters\n", argv[1],count);return 0;}Number of characters in the
populate in a two-dimensional array */ intColums,rows; for(rows =0; rows for(colums =0; Colums "%d", matrix[rows][colums]);//This can also be written here //scanf ("%d", matrix[rows]+colums);} }/** * Find the smallest element of the largest element * */ //To hold the smallest element in the largest element intMininmax =0; for(rows =0; rows //To save the maximum line element intMaxinline =0; for(colums =0; colums if(Matrix[rows][colums] > Maxinline) maxinline = Mat
//// main.cpp// 3-13递归Fibonacci级数//// Created by T.P on 2018/3/21.// Copyright ? 2018年 T.P. All rights reserved.////课本习题3-13.用递归的方法编写函数求Fibonacci级数,//公式为:Fn=Fn-1 + Fn-2 (n>2),F1=F2=1#include //// main.cpp// 3-14递归n阶勒让德多项式//// Created by T.P on 2018/3/21.// Copyright ? 2018年 T.P. All rights reserved.////课本习题3-14//Pn(x)=1, n=0// =x, n=1// =[(2n-1)x*Pn-1(x)-(n-1)Pn-2(x)]/n ,n>1#include "C + +" recursion after class
The C of Ur is SXBK.UR2: There is a root tree divided into a bare topic, the complexity of metaphysics $O (N\sqrt{n}) $.First, the number of multiples of the statistic K is converted.The path of the center of gravity c is divided into two cases: (setting n is the size of the current tree)1, in the sub-tree of C, direct O (n) calculation;2, one in the subtree of
function and find the function code withheld. Here is the main function test code, which compiles through Windows GCC and outputs the correct results:IntMain (void)//programmed by wmydx{Double_train test;Double_train *l = test;l->length = 0;L->head = NULL; C is not object-oriented and therefore cannot be initialized with a constructor function.for (int i = 0;i {Insert (L,i);}View (L);System ("pause");}So how do you flip a linked list in O (1) time? Y
} the return 0; +}# # #7. calculates the total width of an array of English, numeric, and punctuation characters, where the width of the English character is1cm, the digital width is 0.5cm, thepunctuation mark width is 0.8cm. 8. Add the question , if the width of the specified line is 10cm, a character length of more than a string truncation , just so that the width of the 10cm line can accommodate. Output this truncated sub-array. 1 floatGetcharacterweidth (Charc)2 {3 if((
() - { + inta[Ten]={1,2,3,4,5,6,7,8,9,Ten}; - intx; + intLoc; Aprintf"Please enter a number:"); atscanf"%d",x); -Loc=search (X,a,Ten); - if(loc!=-1) - { -printf"%d is in the first%d locations. \ n", x,loc); -}Else{ inprintf"%d does not exist!"); - } to return 0; +}Two-dimensional array: An array of int a[i][j];//i row J columnsExample 3: Read into a matrix of 3*3, judging 0 and 1 who wins. (Nine Gongge games)2. FunctionsThe functions in
This is the first time to publish essays on the blog, hoping to urge themselves not to waste time, and strive to improve the basic skills.1#include 2 3 classCPU4 {5 enumcpu_rank{p1=1, P2,P3,P4,P5,P6,P7};6 Public:7CPU () =default;8CPU (enumCpu_rank);9~CPU () {}Ten voidRun () {std::cout"CPU Run";} One voidStop () {std::cout"CPU Stop";} A }; - - enumRam_type {ddr4=1, DDR3,DDR2}; the classRAM - { - enumram_type type; - intsize; + floatPing; - Public: +RAM () =default; ARAM
of simulating a keyboard entry into letters and numbers, and the characters entered must be defined first in the keycodedic. Analog keyboard input can not be continuously continuous input, if the time of two entry is too short and the content is consistent may cause the latter entry invalid, as shown in line 6.Code Snippet 16-14 Public Static BOOLInput (stringstr) { foreach(CharChinchStr. ToUpper ()) {//The analog click Key can evade or prolong the thread.sleep when the continuous input key
Chapter 9 exercises in C ++ meditationPaste the code first, and add a summary tomorrow!
# Ifndef PICTURE_H # define PICTURE_H # include
Using namespace std; class Picture {private: int height, width; char * data; char position (int row, int col) {return data [row * width + col];} char position (int row, int col) const {return data [row * width + col];} static int max (int m, int n) {return m> n? M: n;
Professor 100 Yuan/hour Associate Professor 80 Yuan/hour lecturer 60 yuan/hour TA 40 yuan/hourEnter the teacher's name, teaching hours, and output the teacher's remuneration#include This topic learns the use of the string type and string (), using this to #includeThis article from "Blue Domain Creeps" blog, declined reprint!The eighth question of C + + exercises
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.