Programmer account notes (3)

xiaoxiao2021-03-06  85

Soon, it was the third day, and the next learning task should be more and more heavy. As for what today, I don't think it is similar to what I think of it. Maybe because I have already understood the reason why this today is talking about. However, I have to write down today, and there is no special reason. I want to have a memories.

Today is all about arrays, we define different arguments and other advanced language definitions in C language, which shows C language and other languages.

C language foxbase

INT A [10] [10]; DIM A (10, 10)

Is it a symbol, and we used to use a small parentheses, but now it is really uncomfortable? But who told us to learn C language, don't get used to it. I still remember that the previous quoted group is not to pay attention to its address, I only know that I will use it, even if I use it, I will compile errors. But the C language is not, after you define an array, you have to take a good control, because the number of borders will never notify you. The definition and calling method of arrays is also a lot, really flexible, there is no longer repeating the things. Now define an array to see:

Int a [10];

As shown in this table, there is a relative address after the array definition, and the array name A is the first address of these addresses. Now we define more integer pointer variable INT * P; let him point to array a, p = a; we try to make pointer operations to increase a P ; we see the result is P pointing to the new address 2003, original The address is 2001. Why is it to increase one? Isn't it 2002 right? In fact, this will explain why we define the pointer variables, because all the pointer operations are also what kind of operations made by what type of pointers themselves are, it is now integrity, integer data storage is required for 2 words. The knit, so the needle finger operation is also carried out in this way, and the results are obviously moving down. In fact, here is so much, the book is basically detailed in the book, so I first said that as long as I have read the book, it should be very easy to understand (but there may be blurred it on it).

Ok, let's make some questions, this is the question of today's teacher gives us, in fact, the topic that appears in the 2001 program afternoon exam. So please do it yourself, think more, see who is better. In the N line N column matrix, each line has the maximum number, this program seeks the minimum of these maximum numbers.

#include

#define n 100

INT A [N] [N];

void main ()

{

INT ROW, COL, MAX, MIN, N;

/ * Enter a legal N and N * n integer code, note, a part of a part of the back practice to do it back * /

For (row = 0; row

{

For (max = a [row] [0], col = 1; col

IF () max = a [row] [col];

IF () min = max;

ELSE IF () min = max;

}

Printf ("The minimum of the maximum:% D / N", min);

}

This question can be really difficult, it is difficult to get it in the second empty, I believe that the first space will do, but the second empty, really don't. At that time, the final continued why two empty statements were the same, but it really didn't want to talk, but he had to die, and he always thought must be an array. The first cycle is in the first cycle, follow It is listed. But I still can't think of the answer, because my idea has been wrong. Finally, the teacher still said the answer, but also said that this question is really difficult. The second empty is actually filling ROW = = 0, why do you fill this, because this matrix must have a base number, so row = 0 only once, and it is natural to become the first comparison. The base, follow this IF statement is to compare the minimum number of these maximum numbers, the second air fills out of course the answer can also come out, I can come out, because of the integers The problem of type boundaries, the weight I have edited.

Printf ("Please Input N:"); Scanf ("% D", & n); for (row = 0; row

For (COL = 0; col

{

DO

{

Printf ("Please a [% D] [% D]", ROW, COL);

Scanf ("% D", & a [row] [col]);

WHILE (a [row] [col] <- 32767 && a [row] [col]> 32767);

}

The next thing is the second question, the topic is as follows: seeking N * N diagonal and this question because all written by themselves, so various ways of writing. Let's write my most basic simple way below.

#include

#define n 5

Main ()

{

INT A [N] [N];

Int row, col;

INT SUM = 0;

/ * Enter a slight * /

For (Row = COL = 0; ROW

SUM = a [row] [col];

For (Row = 0, COL = N-1)

SUM = a [row] [col];

IF (n% 2! = 0)

Sum- = a [n / 2] [n / 2];

Printf ("% d", max);

}

This is the most basic method, two cycles follow the number of judges whether or not the number of occasion occurs, so that the result is

Below I wrote a relatively simple amount of my classmates, and the method is unique (anyway, everyone has never thought of this method, except for him). Here is the main way to write his way.

Int sum = 0, j;

For (j = 0; J

SUM = A [J] [J] A [J] [N-1-J];

IF (n% 2! = 0)

Sum- = a [n / 2] [n / 2];

Simple enough, one cycle can be, his idea is like this, there is a matrix as follows

Each time two two are just relative, so it can be scanned once. Ok, I have some tired of writing, because there is no spirit today, the final teacher has added another simpler, the method is actually a kind of conditional operator SUM = A [J] [J] (((( J == (N-1-j) 0: a [j] [n-1-j]; C language really wants to have more simple and simple.

转载请注明原文地址:https://www.9cbs.com/read-124137.html

New Post(0)