Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <math.h>
- int main() {
- int n, m;
- scanf("%d%d", &n, &m);
- float mat[n][m];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- scanf("%f", &mat[i][j]);
- }
- }
- float x;
- scanf("%f", &x);
- for(int i = 0; i < n; i++) {
- float najmal = fabs(x - mat[i][0]);
- for(int j = 0; j < m; j++) {
- if(fabs(x - mat[i][j]) < najmal) {
- najmal = fabs(x - mat[i][j]);
- }
- }
- printf("%f\n", najmal);
- printf("Redica %d i kolona: ", i);
- for(int j = 0; j < m; j++) {
- if(najmal == fabs(x - mat[i][j])) {
- printf("%d ", j);
- }
- }
- printf("\n");
- }
- }
- /*
- 4 4
- 1.7 2.0 7.1 1.9
- 7.3 2.2 3.4 1.01
- 6.0 5.1 5.2 4.1
- 4.4 1.0 0.0 1.2
- 4.5
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement