SlideShare a Scribd company logo
1 of 14
Download to read offline
ÇOK BOYUTLU DİZİLER
programlama dilleri 1
- 3. hafta -
Araş. Gör. Nesibe YALÇIN
BİLECİK ŞEYH EDEBALİ ÜNİVERSİTESİ
MÜHENDİSLİK FAKÜLTESİ
BİLGİSAYAR MÜHENDİSLİĞİ BÖLÜMÜ
2
Diziler
― Dizi, aynı tip verilerin birbiri arkasına tanımlanmasıdır.
― Diziler sadece aynı veri türünden değişken değerleri
alabilir.
― Diziler kullanılarak, aynı isimle birden fazla değişkene
erişilebilir ve işlem yapılabilir.
― Diziler kullanılarak işlem sayısı azaltılır, zaman ve
karmaşıklıktan kazanç sağlanır.
3
Tek Boyutlu Diziler
Değişken türü Dizinin ismi [Eleman sayısı]
int a[4]
char x[2]
4
int a[4]
a[0] = 8;
a[1] = 22;
a[2] = -3;
a[3] = 49;
char x[2]
x[0] = ‘?’;
x[1] = ‘k’;
a[4] =
x[2] =
a[0]
a[1]
a[2]
a[3]
x[0]
x[1]
Tek Boyutlu Diziler
5
Tek Boyutlu Diziler
int a[4] = {8, 22, -3, 49}; - int a[] = {8, 22, -3, 49};
char x[2] = {‘?’, ‘k’};
int b[5] = {1, 2, 3, 4, 5, 6}; //hatalı – eleman sayısı
float a[-6]={1.1,2.7,3.3,4.0}; //hatalı – negatif boyut
int a[2.2]={11,22,33,44,55,66}; //hatalı – boyut tam
sayı olmalı
6
Çok Boyutlu Diziler
―Çok boyutlu dizileri, elemanları dizilerden oluşan
diziler olarak düşünebiliriz.
―Diziye eklenen her bir boyut için yine [] işaretleri
arasında bir sayı tanımlanmaktadır.
Değişken türü Dizinin ismi [ElemanSayısı] [ElemanSayısı] ….
Boyut_1 Boyut_2 Boyut …..
7
Çok Boyutlu Diziler
İki boyutlu diziler (matrisler):
Değişken türü Dizinin ismi [Satır Sayısı] [Sütun Sayısı]
int a[4][5]; float x[3][2]; double y[2][2];
Çok boyutlu diziler:
int a[4][3][5]; float x[2][1][3][2]; double y[2][2][2][2][2];
8
Değer Atama
int a[4][2] = {8, 22, -3, 49, 14, 5, -5, 2};
int a[][2] = {8, 22,
-3, 49,
14, 5,
-5, 2};
int a[][2] = {{8, 22}, {-3, 49}, {14, 5}, {-5, 2}};
a[0][0] a[0][1]
a[1][0] a[1][1]
a[2][0] a[2][1]
a[3][0] a[3][1]
4x2
8 22
-3 49
14 5
-5 2
4x2
9
Bellekte Yerleşimi
for(int i=0; i<4; i++)
for(int j=0; j<2; j++)
//scanf("%d",&x[i][j]);
printf("%d",x[i][j]);
Veri
a[0][0] 8
a[0][1] 22
a[1][0] -3
a[1][1] 49
a[2][0] 14
a[2][1] 5
a[3][0] -5
a[3][1] 2
1.Satır
2.Satır
3.Satır
4.satır
8 22
-3 49
14 5
-5 2
4x2
10
Çok Boyutlu Diziler
―İster tek boyutlu, ister çok boyutlu bir dizi içerisinde
bulunan elemanlar, birbiri ardına gelen bellek
hücrelerinde tutulur.
―İlk elemanın boyutunu yazmaya gerek yoktur.
―İlk boyut hariç diğer boyutların eleman sayısı
mutlaka yazılmalıdır.
11
Çok Boyutlu Diziler
―n boyutlu bir diziyi fonksiyona parametre
göndermek;
void topla(int x[][3][2][2],int y[][4])
{
// işlemler
}
int main(){
topla(x,y); //fonksiyon çağırma
}
12
Uygulama Örnekleri
#include <stdio.h>
#include <conio.h>
#define SAT 2
#define SUT 3
int main() {
int a[SAT][SUT]={5, 3, 7, 0, 1, 2};
int b[SAT][SUT]={1, 2, 3, 4, 5, 6};
int c[SAT][SUT];
int i, j;
puts("A Matrisi:");
for(i=0; i<SAT; i++){
for(j=0; j<SUT; j++)
printf("%4d",a[i][j]);
printf("n");
}
puts("B Matrisi:");
for(i=0; i<SAT; i++){
for(j=0; j<SUT; j++)
printf("%4d",b[i][j]);
printf("n");
}
puts("nC Matrisi:");
for(i=0; i<SAT; i++){
for(j=0; j<SUT; j++){
c[i][j] = a[i][j] + b[i][j];
printf("%4d",c[i][j]);
}
printf("n");
}
getch ();
}
13
Uygulama Örnekleri
#include <stdio.h>
#include <conio.h>
void main() {
float not[10][4][3];
int i, j, k;
puts("Notlar:");
for(i=0; i<10; i++)
{
printf("%d.ogrencin",i+1);
for(j=0; j<4; j++)
{
printf("%d.dersin",j+1);
for(k=0; k<2; k++)
{
scanf("%f",&not[i][j][k]);
}
not[i][j][2]=0.4*not[i][j][0]+0.6*not[i][j][1];
printf("Ortalama:%.2fn",not[i][j][2]);
}
}
getch ();
}
14
Uygulama Örnekleri
#include <stdio.h>
#include <conio.h>
void verial(float A[][4][3]){
int i, j, k;
puts("Not Giris:");
for(i=0; i<2; i++){
printf("%d.ogrencin",i+1);
for(j=0; j<4; j++) {
printf("%d.dersin",j+1);
for(k=0; k<2; k++)
scanf("%f",&A[i][j][k]);
A[i][j][2]=0.4*A[i][j][0]+0.6*A[i][j][1]; }
} }
void main(){
float not[2][4][3];
verial(not);
printf("Vize t Final t Ortalama n");
for(int i=0; i<2; i++){
printf("%d.ogrencin",i+1);
for(int j=0; j<4; j++)
printf("%.2f t %.2f t %.2fn",
not[i][j][0],not[i][j][1],not[i][j][2]); }
getch (); }
Fonksiyon tanımlama
Fonksiyon çağırma

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Çok boyutlu diziler

  • 1. ÇOK BOYUTLU DİZİLER programlama dilleri 1 - 3. hafta - Araş. Gör. Nesibe YALÇIN BİLECİK ŞEYH EDEBALİ ÜNİVERSİTESİ MÜHENDİSLİK FAKÜLTESİ BİLGİSAYAR MÜHENDİSLİĞİ BÖLÜMÜ
  • 2. 2 Diziler ― Dizi, aynı tip verilerin birbiri arkasına tanımlanmasıdır. ― Diziler sadece aynı veri türünden değişken değerleri alabilir. ― Diziler kullanılarak, aynı isimle birden fazla değişkene erişilebilir ve işlem yapılabilir. ― Diziler kullanılarak işlem sayısı azaltılır, zaman ve karmaşıklıktan kazanç sağlanır.
  • 3. 3 Tek Boyutlu Diziler Değişken türü Dizinin ismi [Eleman sayısı] int a[4] char x[2]
  • 4. 4 int a[4] a[0] = 8; a[1] = 22; a[2] = -3; a[3] = 49; char x[2] x[0] = ‘?’; x[1] = ‘k’; a[4] = x[2] = a[0] a[1] a[2] a[3] x[0] x[1] Tek Boyutlu Diziler
  • 5. 5 Tek Boyutlu Diziler int a[4] = {8, 22, -3, 49}; - int a[] = {8, 22, -3, 49}; char x[2] = {‘?’, ‘k’}; int b[5] = {1, 2, 3, 4, 5, 6}; //hatalı – eleman sayısı float a[-6]={1.1,2.7,3.3,4.0}; //hatalı – negatif boyut int a[2.2]={11,22,33,44,55,66}; //hatalı – boyut tam sayı olmalı
  • 6. 6 Çok Boyutlu Diziler ―Çok boyutlu dizileri, elemanları dizilerden oluşan diziler olarak düşünebiliriz. ―Diziye eklenen her bir boyut için yine [] işaretleri arasında bir sayı tanımlanmaktadır. Değişken türü Dizinin ismi [ElemanSayısı] [ElemanSayısı] …. Boyut_1 Boyut_2 Boyut …..
  • 7. 7 Çok Boyutlu Diziler İki boyutlu diziler (matrisler): Değişken türü Dizinin ismi [Satır Sayısı] [Sütun Sayısı] int a[4][5]; float x[3][2]; double y[2][2]; Çok boyutlu diziler: int a[4][3][5]; float x[2][1][3][2]; double y[2][2][2][2][2];
  • 8. 8 Değer Atama int a[4][2] = {8, 22, -3, 49, 14, 5, -5, 2}; int a[][2] = {8, 22, -3, 49, 14, 5, -5, 2}; int a[][2] = {{8, 22}, {-3, 49}, {14, 5}, {-5, 2}}; a[0][0] a[0][1] a[1][0] a[1][1] a[2][0] a[2][1] a[3][0] a[3][1] 4x2 8 22 -3 49 14 5 -5 2 4x2
  • 9. 9 Bellekte Yerleşimi for(int i=0; i<4; i++) for(int j=0; j<2; j++) //scanf("%d",&x[i][j]); printf("%d",x[i][j]); Veri a[0][0] 8 a[0][1] 22 a[1][0] -3 a[1][1] 49 a[2][0] 14 a[2][1] 5 a[3][0] -5 a[3][1] 2 1.Satır 2.Satır 3.Satır 4.satır 8 22 -3 49 14 5 -5 2 4x2
  • 10. 10 Çok Boyutlu Diziler ―İster tek boyutlu, ister çok boyutlu bir dizi içerisinde bulunan elemanlar, birbiri ardına gelen bellek hücrelerinde tutulur. ―İlk elemanın boyutunu yazmaya gerek yoktur. ―İlk boyut hariç diğer boyutların eleman sayısı mutlaka yazılmalıdır.
  • 11. 11 Çok Boyutlu Diziler ―n boyutlu bir diziyi fonksiyona parametre göndermek; void topla(int x[][3][2][2],int y[][4]) { // işlemler } int main(){ topla(x,y); //fonksiyon çağırma }
  • 12. 12 Uygulama Örnekleri #include <stdio.h> #include <conio.h> #define SAT 2 #define SUT 3 int main() { int a[SAT][SUT]={5, 3, 7, 0, 1, 2}; int b[SAT][SUT]={1, 2, 3, 4, 5, 6}; int c[SAT][SUT]; int i, j; puts("A Matrisi:"); for(i=0; i<SAT; i++){ for(j=0; j<SUT; j++) printf("%4d",a[i][j]); printf("n"); } puts("B Matrisi:"); for(i=0; i<SAT; i++){ for(j=0; j<SUT; j++) printf("%4d",b[i][j]); printf("n"); } puts("nC Matrisi:"); for(i=0; i<SAT; i++){ for(j=0; j<SUT; j++){ c[i][j] = a[i][j] + b[i][j]; printf("%4d",c[i][j]); } printf("n"); } getch (); }
  • 13. 13 Uygulama Örnekleri #include <stdio.h> #include <conio.h> void main() { float not[10][4][3]; int i, j, k; puts("Notlar:"); for(i=0; i<10; i++) { printf("%d.ogrencin",i+1); for(j=0; j<4; j++) { printf("%d.dersin",j+1); for(k=0; k<2; k++) { scanf("%f",&not[i][j][k]); } not[i][j][2]=0.4*not[i][j][0]+0.6*not[i][j][1]; printf("Ortalama:%.2fn",not[i][j][2]); } } getch (); }
  • 14. 14 Uygulama Örnekleri #include <stdio.h> #include <conio.h> void verial(float A[][4][3]){ int i, j, k; puts("Not Giris:"); for(i=0; i<2; i++){ printf("%d.ogrencin",i+1); for(j=0; j<4; j++) { printf("%d.dersin",j+1); for(k=0; k<2; k++) scanf("%f",&A[i][j][k]); A[i][j][2]=0.4*A[i][j][0]+0.6*A[i][j][1]; } } } void main(){ float not[2][4][3]; verial(not); printf("Vize t Final t Ortalama n"); for(int i=0; i<2; i++){ printf("%d.ogrencin",i+1); for(int j=0; j<4; j++) printf("%.2f t %.2f t %.2fn", not[i][j][0],not[i][j][1],not[i][j][2]); } getch (); } Fonksiyon tanımlama Fonksiyon çağırma