Skip to content

Matrix PTBR #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Matrix with informations PTBR/Matrix explanation PTBR.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Crie um programa que declare uma matriz de dimensão 3x3 e preencha com valores lidos pelo teclado. No final, mostre a matriz na tela, com a formatação correta, mostrando no final:
A) A soma de todos os valores pares digitados.
B) A soma dos valores da terceira coluna.
C) O maior valor da segunda linha.
31 changes: 31 additions & 0 deletions Matrix with informations PTBR/Matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
matriz = []
soma_pares = soma_coluna = maior = 0

for i in range(0, 3):
coluna = []
for j in range(0, 3):
valor = int(input(f'Digite um valor para [{i}, {j}]: '))
coluna.append(valor)

if valor % 2 == 0:
soma_pares += valor
if j == 2:
soma_coluna += valor
if i == 1:
if j == 0:
maior = valor
else:
if valor > maior:
maior = valor
matriz.append(coluna)

print('='*15)
for i in range(0, 3):
for j in range(0, 3):
print(f'[{matriz[i][j] :^5}]', end='')
print()

print('='*15)
print(f'A soma dos valores pares digitados é {soma_pares}')
print(f'A soma dos valores da terceira coluna é {soma_coluna}')
print(f'O maior valor da segunda linha é {maior}')
22 changes: 22 additions & 0 deletions Prime
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>
#include <math.h>

int main(void) {
int num, raiz, contador, i;
i=0;
contador=1;
scanf("%d", &num);
raiz = sqrt(num);
while(contador<=raiz){
if(num%contador==0){
i=i+1;
}
contador=contador+1;
}
if(i==1){
printf("Is prime\n");
}
else
printf("Not is prime\n");
return 0;
}
18 changes: 18 additions & 0 deletions sumofintegers
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <stdio.h>

int main(void){
int a, n, b=0, i;

scanf("%d %d", &a, &n);
while(n<=0){
scanf("%d", &n);
}
for(i=1; i<=n;i++){
b+=a;
a++;
}

printf("%d\n", b);

return 0;
}