Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Recensione HONOR Magic 8 Lite: lo smartphone indistruttibile e instancabile
Recensione HONOR Magic 8 Lite: lo smartphone indistruttibile e instancabile
Abbiamo provato a fondo il nuovo Magic 8 Lite di HONOR, e per farlo siamo volati fino a Marrakech , dove abbiamo testato la resistenza di questo smartphone in ogni condizione possibile ed immaginabile. Il risultato? Uno smartphone praticamente indistruttibile e con un'autonomia davvero ottima. Ma c'è molto altro da sapere su Magic 8 Lite, ve lo raccontiamo in questa recensione completa.
Sony WF-1000X M6: le cuffie in-ear di riferimento migliorano ancora
Sony WF-1000X M6: le cuffie in-ear di riferimento migliorano ancora
WF-1000X M6 è la sesta generazione di auricolare in-ear sviluppata da Sony, un prodotto che punta a coniugare facilità di utilizzo con una elevata qualità di riproduzione dei contenuti audio e una cura nella riduzione del rumore ambientale che sia da riferimento
Snowflake porta l'IA dove sono i dati, anche grazie a un accordo con OpenAI
Snowflake porta l'IA dove sono i dati, anche grazie a un accordo con OpenAI
Snowflake ha presentato diverse novità per la sua piattaforma legate all'intelligenza artificiale. Quella forse più eclatante è una collaborazione con OpenAI, ma non mancano diverse nuove funzionalità che rendono la piattaforma più flessibile e in grado di rispondere meglio alle esigenze in continuo cambiamento delle aziende
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 13-06-2010, 12:30   #1
kwb
Senior Member
 
L'Avatar di kwb
 
Iscritto dal: Jul 2003
Città: Alessandria
Messaggi: 10167
[C]Array multidimensionali, comparazioni di matrici

Ciao a tutti, sto facendo questo programma che prese in input due matrix a e b, il programma in output restituisce se la matrice b è una sottomatrice di a...
Purtroppo, non sono ancora riuscito ad arrivare a questo punto, infatti ho problemi col caricamento dei dati nel vettore... E non capisco cosa non vada...
Infatti, i dati vengo caricati correttamente ( penso ) ma se metto una matrice 4 x 4 i dati inseriti vengono disposti su un'unica riga del terminale ( si noti che 4 è la grandezza massima di righe per la matrice, ho definito una costante apposta per questo ). Se vado invece a mettere una matrice 2 x 2 e scrivo, per esempio:
as
df

Questi mi vengono stampati correttamente... Scrivendo invece, nella 4 x 4:
qwer
tyui
asdf
ghjk

Mi viene stampato:
qwertyuiasdfghjk

Questo è il codice fin ora scritto:
Codice:
/*
 Write a C program that reads from keyboard 2 matrices of characters (of size at most 10x10), and then checks if the second matrix occurs
 as a sub-matrix in the first one.
 For example, let us consider the matrices
		A	B	C	k	F	m2: F G		m3: F G 
 m1:	D	E	F	G	A		K L			K i
		m	I	K	L	i
 
 m2 occurs in m1 as a sub-matrix while m3 does not. Be careful in not crossing the matrix boundaries.
*/

#include <stdio.h>
#define MAX 4 //Change to 10 when done

void get_matrix(char matrix[][MAX], int *n1, int *n2);
void empty_buffer(void);

int main (void) 
{
	int i=0, j=0; //Indexes for matrix 1
	int z=0, c=0; //Indexes for matrix 2
	char matrix[MAX][MAX];
	printf("This program read from keybord 2 matrices\n");
	printf("of character, and checks\n");
	printf("if the second matrix occurs\n");
	printf("as a submatrix in the first one.\n");
	for (i=0; i < MAX; i++)
		matrix[i][i]=0;
	i = 0;
	get_matrix(matrix, &i, &j);
    return 0;
}

void get_matrix(char matrix[][MAX], int *n1, int *n2)
{
	int i1, i2; //Indexes for the matrix, no matter which one
	
	printf("Insert the size ( rows ) of the matrix\n");
	scanf("%d", n1);
	while ( *n1 > MAX || *n1 <= 0 )
	{
		printf("You can enter only a number between 1 and %d\n", MAX);
		scanf("%d", n1);
	}
	printf("Your matrix will have %d rows\n", *n1);
	printf("Now enter the size ( columns ) of the matrix\n");
	scanf("%d", n2);
	while ( *n2 <= 0 )
	{
		printf("Your matrix must have at least 1 column\n");
		scanf("%d", n2);
	}
	printf("Your matrix will have %d columns\n", *n2);
	
	printf("Now enter your matrix, insert the characters for each row sequentially, without any space among them\n");
	printf("The program will automatically position the elements inserted\n");
	empty_buffer();
	for (i1=0; i1 < *n1; i1++)
	{
		for(i2=0; i2 <= *n2; i2++) // i2 has to be less or equal to *n2 because the loop stops only if i2 == *n2, is this the reason??
		{
			scanf("%c", &matrix[i1][i2]);
		}
	}
	printf("\n");
	for (i1=0; i1 < *n1; i1++)
	{
		for(i2=0; i2 <= *n2; i2++) // Same as written above
		{
				printf("%c", matrix[i1][i2]);
		}
	}
	
}

void empty_buffer(void)
{
	while(getchar() != '\n');
}
__________________
Dell XPS 13 (9350) :: i5-2500K - HD6870 - AsRock Z68 Pro3 - Corsair Vengeance 8GB (4x2) DDR3 :: Samsung Galaxy S4 GT-i9505
kwb è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


Recensione HONOR Magic 8 Lite: lo smartphone indistruttibile e instancabile Recensione HONOR Magic 8 Lite: lo smartphone ind...
Sony WF-1000X M6: le cuffie in-ear di riferimento migliorano ancora Sony WF-1000X M6: le cuffie in-ear di riferiment...
Snowflake porta l'IA dove sono i dati, anche grazie a un accordo con OpenAI Snowflake porta l'IA dove sono i dati, anche gra...
Sistema Mesh Roamii BE Pro: il Wi-Fi 7 secondo MSI Sistema Mesh Roamii BE Pro: il Wi-Fi 7 secondo M...
Recensione HUAWEI Mate X7: un foldable ottimo, ma restano i soliti problemi Recensione HUAWEI Mate X7: un foldable ottimo, m...
Hyundai: spunta un'elettrica estremament...
Una connessione diretta con AWS European...
La Toyota Yaris avrà una versione...
Minori sessualizzati da Grok: l'UE mette...
NIO stabilisce il nuovo record di scambi...
Dell Private Cloud sempre più ape...
Ennesimo incidente per la guida autonoma...
Dopo le maniglie, è il turno dei ...
Addio incendi incontrollati? Svolt dice ...
WINDTRE si mette in proprio: vender&agra...
The Mandalorian & Grogu: il trailer ...
OpenClaw sotto attacco: i malware infost...
Resident Evil Requiem: pre-load dal 25 f...
Vaticano, la Messa si traduce in 60 ling...
Kia prepara il facelift della Kia EV5: n...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 23:33.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Served by www3v