What should be done.

Enter an array from the keyboard, perform data transformations, display the array using the printf () formatted output function. Write a program that displays the minimum element of an array of integers entered from the keyboard. Two-dimensional array of real numbers.

So now the program code itself, which I get, but the array does not appear on the screen + the whole loop does not seem to be true either:

#include "stdafx.h" #include <stdio.h> #include <math.h> #include <clocale> #include <memory.h> #include <stdlib.h> #include <time.h> // Π Π°Π±ΠΎΡ‚Π° со строками #include <string.h> // Π‘ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠ° слСдящая Π·Π° Π²Ρ‹Π΄Π΅Π»Π΅Π½ΠΈΠ΅ΠΌ памяти #define _CRTDB_MAP_ALLOC #include <crtdbg.h> int _tmain(int argo, _TCHAR * argv[]) { // Ѐункция находящая всС ΡƒΡ‚Π΅Ρ‡ΠΊΠΈ памяти _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); // Ѐункция ΠΎΡ‚Π²Π΅Ρ‡Π°ΡŽΡ‰Π°Ρ Π·Π° русский язык setlocale(LC_ALL, "Russian"); setlocale(LC_ALL, "rus"); srand(time(NULL)); printf("ΠŸΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ° для вычислСния минимального элСмСнта массива n"); printf(" Π²Π²Π΅Π΄Π΅Π½Π½ΠΎΠ³ΠΎ с ΠΊΠ»Π°Π²ΠΈΠ°Ρ‚ΡƒΡ€Ρ‹n"); float a[3][3] = { 0 }; float b; for (int i = 0; i < 3; i = i + 1) { for (int j = 0; j < 3; j = j + 1) { printf("Π’Π²Π΅Π΄ΠΈΡ‚Π΅ элСмСнт массива\n"); scanf("%f", &b); a[i][j] = b; } printf("%f\n", a[i][j]); } return 0; } 

A lot of superfluous. Do not pay attention: C + + began to study three days ago.

    1 answer 1

    By removing all unnecessary, your current program can be simplified to this:

     #include <cstdio> int main() { float a[3][3]; float b; for (int i = 0; i < 3; i = i + 1) { for (int j = 0; j < 3; j = j + 1) { printf("Π’Π²Π΅Π΄ΠΈΡ‚Π΅ элСмСнт массиваn"); scanf("%f", &b); a[i][j] = b; } printf("%fn", a[i][j]); } 

    Some leading questions:

    • In which of the cycles will printf(... a[i][j]) run?

    • Where does the output format "%fn" come from? Are you familiar with the formatting syntax of real numbers when outputting using printf ?

    • I'm only the second day in this area trying to learn something. I watched about 20 videos on youtube, there everyone does everything differently. Everyone has their own style. I know that% f is responsible for a real number, but what I see is% fn for the first time. printf (... a [i] [j] if regarding the task, then I don’t know, and if regarding what you wrote, then in the second. - ek8800
    • @ ek8800 In the code that you wrote it is "%fn" (although, probably, the hashcode is so \n , so it does not matter). In short, your current code version will only display 3 items on the screen. Correct it so that all items are displayed. - Costantino Rupert
    • @ ek8800 After that, divide your current cycle into 2 different ones - in one let them input, in the other - output (you must run them one after another). - Costantino Rupert
    • @ ek8800 The third and final step is to add another cycle in which there will be a minimal element from the entire array. This step, of course, is inserted between the steps from the previous comments. - Costantino Rupert
    • Thanks for the help - ek8800