User
Pass
2FA
 
 

C++
Go to page Previous  1, 2, 3  Next    
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> Trash -> Programming / Scripting / Database
Author Message7133
mayavin

[Future World]



Status: Offline
(since 23-06-2018 15:49)
Joined: 08 Mar 2012
Posts: 3033, Topics: 173
Location: Cluj-Napoca

Reputation: 119.8
Votes: 48

Post Posted: 12-05-2013, 17:01:54 | Translate post to: ... (Click for more languages)

Daca nu ai inteles cum functioneaza, intrebi.
0 0
  
Back to top
View user's profile Send private message
Csvyo

[UNSTOPPABLE forever!]



Status: Offline
(since 18-10-2019 11:54)
Joined: 12 Jun 2012
Posts: 7694, Topics: 102
Location: Retired

Reputation: 395.4
Votes: 92

 
Post Posted: 14-05-2013, 08:48:06 | Translate post to: ... (Click for more languages)

mayavin wrote:
Daca nu ai inteles cum functioneaza, intrebi.

Nu trebuia sa initializezi si i si j?Noi asa facem la scoala.


So many words untold...

0 0
  
Back to top
View user's profile Send private message
nr913
[Banned user]


Banned


Status: Offline
(since 24-10-2013 10:06)
Joined: 24 Apr 2009
Posts: 4224, Topics: 223
Location: România

Reputation: 60.3
Votes: 156

 
Post Posted: 14-05-2013, 09:29:53 | Translate post to: ... (Click for more languages)

Le-a inițializat în for
Quote:
for (int i = 0; ...


Attitude - A little thing that makes a BIG difference
0 0
  
Back to top
View user's profile Send private message
Csvyo

[UNSTOPPABLE forever!]



Status: Offline
(since 18-10-2019 11:54)
Joined: 12 Jun 2012
Posts: 7694, Topics: 102
Location: Retired

Reputation: 395.4
Votes: 92

 
Post Posted: 14-05-2013, 09:55:43 | Translate post to: ... (Click for more languages)

nr913 wrote:
Le-a inițializat în for
Quote:
for (int i = 0; ...

ciudat -),noi la scoala le initializam la inceput.
Sa inteleg ca se poate face si fara sa initializezi la inceput nu?


So many words untold...

0 0
  
Back to top
View user's profile Send private message
nr913
[Banned user]


Banned


Status: Offline
(since 24-10-2013 10:06)
Joined: 24 Apr 2009
Posts: 4224, Topics: 223
Location: România

Reputation: 60.3
Votes: 156

 
Post Posted: 14-05-2013, 10:00:41 | Translate post to: ... (Click for more languages)

Poți sã le inițializezi (aproape) oriunde.

Attitude - A little thing that makes a BIG difference
0 0
  
Back to top
View user's profile Send private message
Csvyo

[UNSTOPPABLE forever!]



Status: Offline
(since 18-10-2019 11:54)
Joined: 12 Jun 2012
Posts: 7694, Topics: 102
Location: Retired

Reputation: 395.4
Votes: 92

 
Post Posted: 14-05-2013, 10:12:55 | Translate post to: ... (Click for more languages)

Poti sa imi explici pasii cu care ai inceput scriptarea programului?De exemplu de ce ai pus la inceput cout si nu ai inceput cu for etc...?

So many words untold...

0 0
  
Back to top
View user's profile Send private message
mayavin

[Future World]



Status: Offline
(since 23-06-2018 15:49)
Joined: 08 Mar 2012
Posts: 3033, Topics: 173
Location: Cluj-Napoca

Reputation: 119.8
Votes: 48

Post Posted: 14-05-2013, 10:39:18 | Translate post to: ... (Click for more languages)

Am pus cout<<"n= "; (numarul de linii si coloane a matricii) ca sa stii ce trebuie sa introduci atunci cand rulezi programul.
Daca nu puneam cout, nu iti aparea nimic cand rulai si trebuie sa "stii tu" ca trebuie sa introduci un numar n.

0 0
  
Back to top
View user's profile Send private message
Csvyo

[UNSTOPPABLE forever!]



Status: Offline
(since 18-10-2019 11:54)
Joined: 12 Jun 2012
Posts: 7694, Topics: 102
Location: Retired

Reputation: 395.4
Votes: 92

 
Post Posted: 14-05-2013, 11:25:35 | Translate post to: ... (Click for more languages)

f>>n;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
f>>a[i][j];
for(int i=1;i<=n;i++) ?
f>>n insemnand...?
si inca ceva pt i=1 i<n i++=?


So many words untold...

0 0
  
Back to top
View user's profile Send private message
mayavin

[Future World]



Status: Offline
(since 23-06-2018 15:49)
Joined: 08 Mar 2012
Posts: 3033, Topics: 173
Location: Cluj-Napoca

Reputation: 119.8
Votes: 48

Post Posted: 14-05-2013, 11:39:02 | Translate post to: ... (Click for more languages)

Ai vazut ca la inceput am declarat ifstream f("matrice.in");
f>>n; inseamna ca din fisierul f citesc un numar n de pe prima linie a fisierului;

for(i=1;i<=n;i++) . i este un contor cu care faci parcurgerea matricii, pornind de pe prima linie pana la linia n. De fiecare data linia creste cu o unitate.

La fel este si cu for(j=1;j<=n;j++) - parcurg coloanele.

0 0
  
Back to top
View user's profile Send private message
Csvyo

[UNSTOPPABLE forever!]



Status: Offline
(since 18-10-2019 11:54)
Joined: 12 Jun 2012
Posts: 7694, Topics: 102
Location: Retired

Reputation: 395.4
Votes: 92

 
Post Posted: 14-05-2013, 11:56:57 | Translate post to: ... (Click for more languages)

nici asta nu inteleg:
if((i==1) || (i==n) || (j==1) || (j==n))
g<<a[i][j]<<" ";
else
g<<"0 ";
mai bine zis partea cu if(...)||
adica de ce ai pus ||
iar g<<whatever inseamna ca in fisierul g sa apara whatever?


So many words untold...

0 0
  
Back to top
View user's profile Send private message
mayavin

[Future World]



Status: Offline
(since 23-06-2018 15:49)
Joined: 08 Mar 2012
Posts: 3033, Topics: 173
Location: Cluj-Napoca

Reputation: 119.8
Votes: 48

Post Posted: 14-05-2013, 12:07:00 | Translate post to: ... (Click for more languages)

Deci am facut alea 2 for-uri cu care parcurg matricea, cum am zis mai sus.
|| inseamna SAU.
In acel caz
i==1 - daca sunt pe linia 1
SAU
i==n - daca sunt pe linia n
SAU
j==1 - daca sunt pe coloana 1
SAU
j==n - daca sunt pe coloana n
atunci
in fisierul g afisez elementul de pe linia i si coloana j, adica a[i][j] urmat de un spatiu (" " - ca sa nu fie fiecare cifra una langa alta)

.

ELSE inseamna altfel.
Deci daca nu sunt in situatia de mai sus, atunci afisez in fisierul g un 0 urmat de un spatiu. Un exemplu apare in postul in care ti-am trimis codul si apar si fiserele.

0 0
  
Back to top
View user's profile Send private message
Csvyo

[UNSTOPPABLE forever!]



Status: Offline
(since 18-10-2019 11:54)
Joined: 12 Jun 2012
Posts: 7694, Topics: 102
Location: Retired

Reputation: 395.4
Votes: 92

 
Post Posted: 14-05-2013, 12:14:11 | Translate post to: ... (Click for more languages)

aha ok mersi foarte mult -
maine dau teza si cred ca voi mai pune cateva intrebari diseara
oricum multumesc de TOT ajutorul de pana acum -


So many words untold...

0 0
  
Back to top
View user's profile Send private message
Csvyo

[UNSTOPPABLE forever!]



Status: Offline
(since 18-10-2019 11:54)
Joined: 12 Jun 2012
Posts: 7694, Topics: 102
Location: Retired

Reputation: 395.4
Votes: 92

 
Post Posted: 14-05-2013, 19:45:36 | Translate post to: ... (Click for more languages)

inca ceva.....de ce ai pus ifstream si of stream si nu ai pus ios::in?

So many words untold...

0 0
  
Back to top
View user's profile Send private message
mayavin

[Future World]



Status: Offline
(since 23-06-2018 15:49)
Joined: 08 Mar 2012
Posts: 3033, Topics: 173
Location: Cluj-Napoca

Reputation: 119.8
Votes: 48

Post Posted: 14-05-2013, 19:54:39 | Translate post to: ... (Click for more languages)

Poti pune fstream f("matrice.in", ios::in) sau ifstream f("matrice.in") . E acelasi lucru.

SAU

Poti pune fstream g("matrice.out",ios::out) sau ofstream g("matrice.out"). E acelasi lucru.

0 0
  
Back to top
View user's profile Send private message
Csvyo

[UNSTOPPABLE forever!]



Status: Offline
(since 18-10-2019 11:54)
Joined: 12 Jun 2012
Posts: 7694, Topics: 102
Location: Retired

Reputation: 395.4
Votes: 92

 
Post Posted: 15-05-2013, 18:18:20 | Translate post to: ... (Click for more languages)

Alta problema -
O matrice patratica pe care o imparti in 4 patrate si trebuie sa afiseze patratul 1 si 4.Aceleasi fisier si ar trebui sa arate cam asa:

1 1 1 0 0 0
2 2 2 0 0 0
3 3 3 0 0 0
0 0 0 4 4 4
0 0 0 5 5 5
0 0 06 6 6
Mentionez ca 0 nu trebuie sa apara adica in locul lui sa fie blank.Mai sus am dat un exemplu cu patratele 1 si 4.Cele subliniate trebuie sa apara.
Multumesc -


So many words untold...

0 0
  
Back to top
View user's profile Send private message
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> Trash -> Programming / Scripting / Database  
Go to page Previous  1, 2, 3  Next    


The time now is 12-02-2025, 04:19:08
Copyright info

Based on phpBB ro/com
B

 
 
 







I forgot my password


This message appears only once, so
like us now until it's too late ! :D
x