#include <iostream>
using namespace std;
int main() {
int matriz[3][4];
int L, C;
// inserir os valores pelo teclado
for(L=0;L<3;L++)
{
for(C=0;C<4;C++)
{
cin>>matriz[L][C];
}
}
// for que imprime os valores da matriz
for(L=0;L<3;L++)
{
for(C=0;C<4;C++)
{
cout<<matriz[L][C]<<" ";
}
cout << "\n";
}
return 0;
}
Matemática Pura, Matemática Aplicada, Computação, educação matemática, teoria dos números, programação e desenvolvimento de jogos. - Matheus Nakade - @MorgaoFreud
quarta-feira, 6 de novembro de 2019
matriz 2 indice do lugar para dar o valor
#include <iostream>
using namespace std;
int main() {
int matriz[3][4];
int L, C;
// lendo os valores para as variaveis da matriz
for(L=0;L<3;L++)
{
for(C=0;C<4;C++)
{
matriz[L][C]=L;
}
}
// for que imprime os valores da matriz
for(L=0;L<3;L++)
{
for(C=0;C<4;C++)
{
cout<<matriz[L][C]<<" ";
}
cout << "\n";
}
return 0;
}
using namespace std;
int main() {
int matriz[3][4];
int L, C;
// lendo os valores para as variaveis da matriz
for(L=0;L<3;L++)
{
for(C=0;C<4;C++)
{
matriz[L][C]=L;
}
}
// for que imprime os valores da matriz
for(L=0;L<3;L++)
{
for(C=0;C<4;C++)
{
cout<<matriz[L][C]<<" ";
}
cout << "\n";
}
return 0;
}
matriz 1 array bidimencional array de array linha e coluna
#include <iostream>
using namespace std;
int main() {
int matriz[3][4];
int L, C;
matriz[0][0]=0;
matriz[0][1]=0;
matriz[0][2]=0;
matriz[0][3]=0;
matriz[1][0]=1;
matriz[1][1]=1;
matriz[1][2]=1;
matriz[1][3]=1;
matriz[2][0]=2;
matriz[2][1]=2;
matriz[2][2]=2;
matriz[2][3]=2;
for(L=0;L<3;L++)
{
for(C=0;C<4;C++)
{
cout<<matriz[L][C]<<" ";
}
cout << "\n";
}
return 0;
}
using namespace std;
int main() {
int matriz[3][4];
int L, C;
matriz[0][0]=0;
matriz[0][1]=0;
matriz[0][2]=0;
matriz[0][3]=0;
matriz[1][0]=1;
matriz[1][1]=1;
matriz[1][2]=1;
matriz[1][3]=1;
matriz[2][0]=2;
matriz[2][1]=2;
matriz[2][2]=2;
matriz[2][3]=2;
for(L=0;L<3;L++)
{
for(C=0;C<4;C++)
{
cout<<matriz[L][C]<<" ";
}
cout << "\n";
}
return 0;
}
vetor 2 sem precisar alterar tamanho do vetor toda hora
sem precisar alterar tamanho do vetor toda hora
#include <iostream>
using namespace std;
int main() {
int vetor[7], i;
vetor[0]=10;
vetor[1]=20;
vetor[2]=30;
vetor[3]=40;
vetor[4]=50;
vetor[5]=60;
vetor[6]=70;
for(i=0;i<sizeof(vetor)/4;i++)
{
cout << vetor[i] <<endl;
}
return 0;
}
----------------------------------------------------------------------------------------------------------
ou
#include <iostream>
using namespace std;
int main() {
int tam = 7;
int vetor[tam], i;
vetor[0]=10;
vetor[1]=20;
vetor[2]=30;
vetor[3]=40;
vetor[4]=50;
vetor[5]=60;
vetor[6]=70;
for(i=0;i<tam;i++)
{
cout << vetor[i] <<endl;
}
return 0;
}
--------------------------------------------------------------------------------------------------------------------
ou
#include <iostream>
using namespace std;
int main() {
int vetor[7]={10,20,30,40,50,60,70}, i;
for(i=0;i<7;i++)
{
cout << vetor[i] <<endl;
}
return 0;
}
----------------------------------------------------------------------------------------------------------------------------
#include <iostream>
using namespace std;
int main() {
int vetor[7]={10,20,30,40,50,60,70}, i;
for(i=0;i<sizeof(vetor)/4;i++)
{
cout << vetor[i] <<endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main() {
int vetor[7], i;
vetor[0]=10;
vetor[1]=20;
vetor[2]=30;
vetor[3]=40;
vetor[4]=50;
vetor[5]=60;
vetor[6]=70;
for(i=0;i<sizeof(vetor)/4;i++)
{
cout << vetor[i] <<endl;
}
return 0;
}
----------------------------------------------------------------------------------------------------------
ou
#include <iostream>
using namespace std;
int main() {
int tam = 7;
int vetor[tam], i;
vetor[0]=10;
vetor[1]=20;
vetor[2]=30;
vetor[3]=40;
vetor[4]=50;
vetor[5]=60;
vetor[6]=70;
for(i=0;i<tam;i++)
{
cout << vetor[i] <<endl;
}
return 0;
}
--------------------------------------------------------------------------------------------------------------------
ou
#include <iostream>
using namespace std;
int main() {
int vetor[7]={10,20,30,40,50,60,70}, i;
for(i=0;i<7;i++)
{
cout << vetor[i] <<endl;
}
return 0;
}
----------------------------------------------------------------------------------------------------------------------------
#include <iostream>
using namespace std;
int main() {
int vetor[7]={10,20,30,40,50,60,70}, i;
for(i=0;i<sizeof(vetor)/4;i++)
{
cout << vetor[i] <<endl;
}
return 0;
}
vetor 1 basico
#include <iostream>
using namespace std;
int main() {
int vetor[5], i;
vetor[0]=10;
vetor[1]=20;
vetor[2]=30;
vetor[3]=40;
vetor[4]=50;
for(i=0;i<5;i++)
{
cout << vetor[i] <<endl;
}
return 0;
}
using namespace std;
int main() {
int vetor[5], i;
vetor[0]=10;
vetor[1]=20;
vetor[2]=30;
vetor[3]=40;
vetor[4]=50;
for(i=0;i<5;i++)
{
cout << vetor[i] <<endl;
}
return 0;
}
Assinar:
Comentários (Atom)