daprogramebis safuZvlebileqcia #4


The Presentation inside:

Slide 0

daprogramebis safuZvlebi leqcia #4 2009-2010 sasw.w. I semestri Tsu asoc. prof. naTela arCvaZe Tsu, zusti da sabunebismetyvelo mecnierebaTa fakulteti, kompiuterul mecnierebaTa mimarTuleba 1


Slide 1

wina leqciaze: marTvis Setyobinebebi pirobiTi: if Setyobineba if-else Setyobineba ciklis: while Setyobineba break Setyobineba continue Setyobineba 2


Slide 2

Tema: masivebi da ricxvebis wakiTxva tipi masivis_saxeli [ ganzomileba ] int data_list[3]; masivis elementebia: data_list[0], data_list[1], data_list[2] data_list[3] -ar aris elementi 3


Slide 3

magaliTi: davTvaloT 4 ricxvis jami da saSualo ariTmetikuli float data[4]; /* cvladebi, romelTaTvisac viTvliT jams da saSualo mniSvnelobas */ float total; /* cvladi jamisTvis */ float average; /* cvladi saSualo mniSvnelobisTvis */ int main() { data[0] = 54.0; data[1] = 18.0; data[2] = 34.0; data[3] = 91.0; total = data[0] + data[1] + data[2] + data[3]; average = total / 4.0; printf("Total =%f\t Average =%f\n", total, average); return (0);} 4


Slide 4

striqonebi char saxeli [ ganzomileba] ?\0? - end-of-string char name[6]; int main() { name[0] = ?H?; name[1] = ?e?; name[2] = ?l; name[3] = ?l?; name[4] = ?o?; name[5] = ?\0?; return (0); } 5


Slide 5

striqonuli mudmivebi - "..." name = ?Hello?; /* = arasworia */ magaliTi: include <string.h> char name[6]; int main() { strcpy(name, "Hello"); /* name -is inicializeba */ printf("%s\n", name); /* name -is dabeWdva */ return (0); } 6


Slide 6

striqonuli mudmiva - ormag brWyalebSi (?), mag. ?X? - ikavebs or baits simboluri mudmiva - erTmag brWyalebSi (?). mag. ?X? - ikavebs erT baits. standartuli funqciebi 7


Slide 7

magaliTi #include <string.h> #include <stdio.h> #include <stdlib.h> char first[100]; /* saxeli */ char last[100]; /* gvari */ char full_name[200]; /* saxeli da gvari erTad */ int main(){ strcpy(first, "Galaqtion"); /* saxelis inicializeba */ strcpy(last, "Tabidze"); /* gvaris inicializeba */ strcpy(full_name, first); /* full = "Galaktion" */ strcat(full_name, " "); /* full = " Galaktion " */ strcat(full_name, last); /* full = " Galaktion Tabidze" */ printf("The full name is %s\n", full_name); system("PAUSE"); return (0); } 8


Slide 8

striqonebis wakiTxva da beWdva gets (parametri); Enter - ?\n?(end-of-line) amatebs ?\0? puts (parametri); #include <stdio.h> 9


Slide 9

magaliTi striqonebze: #include <string.h> #include <stdio.h> char line[100]; int main() { printf("Enter a line: "); gets(line); puts("We have read:"); puts(line); printf("The length of the line is: %d\n", strlen(line)); return (0); }         10


Slide 10

mravalganzomilebiani masivebi tipi masivis_saxeli [ ganz1 ] [ ganz2 ] int matrix[3][4]; 3x4=12 elementi float four_dimensions[10][12][9][5]; 10x12x9x5 elementi 11


Slide 11

masivis inicializeba int x[3] = {11, 823, 43}; igivea, rac x[0]= 11; x[1]=823; x[2]=43; int x[] = {11, 823, 43}; int matrix[2][3] ={{1, 2, 3},{10, 20, 30}}; int matrix[2][3] = {1, 2, 3, 10, 20, 30}; char name[] = {'H', 'e', 'l', 'l', 'o','\0'}; char name[] = ?Hello?; char name[50] = ?Hello?; elem. raodenobaa 6=5+1 ('\0') 12


Slide 12

scanf(formati, &cvl1, &cvl2 . . .); #include <stdio.h> #include <stdlib.h> int value; int main() { printf("Enter a value: "); scanf("%d", &value); printf("Twice %d is %d\n", value, value * 2); system("PAUSE"); return (0); } ricxvebis wakiTxva 13


Slide 13

informaciis Setana-gamotanis gadamisamarTeba. funqcia freopen stdin-Setanis standartuli nakadi stdout-gamotanis standartuli nakadi stderr-Secdomebis standartuli nakadi failidan wakiTxva – reJimia r(read) freopen (striqoni1, striqoni2, stdin); freopen ("c:\monacemebi\data.txt", "r", stdin); 14


Slide 14

failSi Cawera-reJimi w (write) freopen (striqoni1, striqoni2, stdout); freopen ("c:\shedegi.txt", "w", stdout); magaliTi: #include<stdio.h> int main() { int a, b, c; float sashualo; freopen( "monacemebi.txt", "r", stdin); scanf("%d%d%d", &a, &b, &c); sashualo =(a+b+c)/3.; freopen( "pasuxi.txt", "w", stdout); printf("%d %d %d ricxvebis ", a, b, c); printf("sashualo ariTmetikuli = %f ", sashualo); return 0; } 15


Slide 15

kursis kategoriebi: kompiuteruli mecnierebebi kursi: daprogramebis safuZvlebi- 2009 Semodgoma ????????????: ?????? ??????? http://moodle.science.tsu.ge/ 16


×

HTML:





Ссылка: