Commit 7799bd23 by tonis2

add first lesson

parents
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
\ No newline at end of file
File added
<diagram program="umletino" version="14.4.0-SNAPSHOT"><zoom_level>10</zoom_level><element><id>UMLClass</id><coordinates><x>310</x><y>170</y><w>100</w><h>30</h></coordinates><panel_attributes>SimpleClass</panel_attributes><additional_attributes></additional_attributes></element></diagram>
\ No newline at end of file
#include <stdio.h>
//Leiame peadiagonaali elementide summa
int main(void)
{
int N, i, j, S = 0;
do
{
printf("Sisestage ruutmatriksi mõõde N\n");
scanf("%d", &N);
} while (N <= 0);
int A[N][N];
// Sisestus blokk
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
printf("Sisestage arv kohal A[%d][%d]\n", i, j);
scanf("%d", &A[i][j]);
}
}
// //Tootlus blokk
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
if (A[i][j] > 0) //On Leitud vähemalt üks liige
{
if (S == 0) { // 0-iga ei saa korrutada
S = 1;
}
S = S * A[i][j];
}
}
}
printf("Vastus int:%d\n", S);
return 0;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment