TuTaMixx Posted March 11, 2012 Share Posted March 11, 2012 merhaba arkadaşlar bende 4 adet değişken var ve bu 4 değişkenin +1 -1 ve 0 gibi değerleri var.benim istediğim bu 4 değişkenden pozitif olanları ayrı toplayıp negatif olanları ayrı toplayıp ayrı ayrı labellara yazdırmak ancak bir türlü beceremedim yani 1.değişken değeri = +1 2.değişken değeri = -1 , 3. değişken değeri = 0, 4. değişken değeri= +1 ise label1 e +2 yazıp label 2 de -1 yazıp 0 içinde hiç birşey yapmaması lazım bunun kodlaması nasıldır ? şimdiden teşekkürler. Quote Link to comment Share on other sites More sharing options...
nezcafe Posted March 11, 2012 Share Posted March 11, 2012 [b]degiskenleri degisken[n] dizisinde tutalim.[/b] [code]for(int i=0;i<degiskensayisi;i++) if(degisken[i]<0) negatif+=degisken[i] if(degisken[i]>0) pozitif+=degisken[i] label1.Text=negatif label2.Text=pozitif[/code] Kodları kabaca yazdım, anlamadıysan daha detaylandırayım. Quote Link to comment Share on other sites More sharing options...
600 Posted March 11, 2012 Share Posted March 11, 2012 int sayi= Convert.ToInt32(textBox1.Text); if (sayi > 0) { MessageBox.Show("Pozitif."); } else if (sayi < 0) { MessageBox.Show("Negatif."); } Quote Link to comment Share on other sites More sharing options...
TuTaMixx Posted March 11, 2012 Author Share Posted March 11, 2012 benim şimdi 4 tane değişken var durum0,durum1,durum2,durum3 bu değişkenlere göre kodu yazıp verebilirmisin bu değişkenlerin değerleri programın içinde belli.yani kullanıcı girmeyecek. Quote Link to comment Share on other sites More sharing options...
TuTaMixx Posted March 11, 2012 Author Share Posted March 11, 2012 [quote name='600' date='11 March 2012 - 22:06 ' timestamp='1331496392' post='1168070'] int sayi= Convert.ToInt32(textBox1.Text); if (sayi > 0) { MessageBox.Show("Pozitif."); } else if (sayi < 0) { MessageBox.Show("Negatif."); } [/quote] senin yaptığın çok ayrı birşey . benim istediğim değişkenlerde pozitif olanları ayrı bir yerde toplayıp ve negatifleride ayrı bir yerde toplayıp ayrı ayrı labellara yazdırmak. Quote Link to comment Share on other sites More sharing options...
nezcafe Posted March 11, 2012 Share Posted March 11, 2012 [quote name='TuTaMixx' date='11 March 2012 - 20:12 ' timestamp='1331496773' post='1168075'] benim şimdi 4 tane değişken var durum0,durum1,durum2,durum3 bu değişkenlere göre kodu yazıp verebilirmisin bu değişkenlerin değerleri programın içinde belli.yani kullanıcı girmeyecek. [/quote] istersen teamviewer ile 1 dakikada halledeyim, şimdi bütün kodları buradan yazmayayım. Quote Link to comment Share on other sites More sharing options...
cumman Posted March 13, 2012 Share Posted March 13, 2012 int pozitiftoplam =0; int negatiftoplam =0; if(durum0 > 0) { pozifittoplam = pozitiftoplam +durum0; } if(durum0<0) { negatiftoplam = negatiftoplam + durum0; } if(durum1 > 0) { pozifittoplam = pozitiftoplam +durum1; } if(durum1<0) { negatiftoplam = negatiftoplam + durum1; } if(durum2 > 0) { pozifittoplam = pozitiftoplam +durum2; } if(durum2<0) { negatiftoplam = negatiftoplam + durum2; } if(durum3 > 0) { pozifittoplam = pozitiftoplam +durum3; } if(durum3<0) { negatiftoplam = negatiftoplam + durum3; } label1.Text="Pozitif Toplamlar: " + pozitiftoplam; label2.Text = "Negatif Toplamlar: " + negatiftoplam; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.