Commit 9c5f51bd by videid

lab6 & 7

parent fefe20b5
Showing with 80 additions and 0 deletions
##TASK1
i= int
j= int
x=0
y=0
som = []
def algorithm() :
print("select n")
n = int(input())
if (0<=n<=10) :
print("select m")
m= int(input())
if (0<=m<=10):
A = [[0 for x in range(n)] for y in range(m)]
for i in range(0,n):
for j in range (0,m):
print("enter element","[",i,"]","[",j,"]")
A[i][j] = int(input())
for h in range (0,min(m,7)):
som.append(0)
for g in range (0 , n):
som[h] = som[h] + A[g][h]
return A,som
## i don't really get the second question
##,if it is asked to return only the negative
##sums here is the code :
##if som[h] < 0 listofnegativesums.append(som[h]):
## return listofnegativesums
##maybe it is about returning a sum
##of only negative elemtents from the rows
##in which case here is the solution:
##for h in range (0,min(m,7)):
## som.append(0)
## for g in range (0 , n):
## if A[g][h] < 0 :
## som[h] = som[h] + A[g][h]
## return A,som
##TASK2
def banknotes():
print("enter S")
S = int(input())
print("enter number of different Bij")
NbBij = int(input())
B = []
for l in range(NbBij):
print("enter Bij size",l)
Bijsize = int(input())
B.append([Bijsize])
print("enter number of Bij",Bijsize)
NbofBij = int(input())
B[l].append(NbofBij)
return B
## the question 3 is a complex mathematical problem i have no idea
##how to resolve,the python implementation would be easier though
\ No newline at end of file
#include <stdio.h>
#define ARRAY_SIZE 25
int function(int input);
int main() {
int array[ARRAY_SIZE] = { 0 };
for (int i = 0; i < ARRAY_SIZE; i++) {
array[i] = function(i);
}
for (int j = 0; j < ARRAY_SIZE;j++) {
int b = array[j];
printf("", array[j]);
}
return 0;
}
int function(int input) {
return (input * (input - 1));
}
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