AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters > C/C++
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Apr 22, 2005, 17:40   #1
Профессор
 
Nikita's Avatar
 
Join Date: Jan 2005
Location: Perm
Posts: 2,142
Rep Power: 4
Reputation: 10
Send a message via ICQ to Nikita
Wink задачка для ассов c/c++

с виду тривиальная задачка ...

#include <stdio.h>
int main (int argc, unsigned char **argv) {
int i = 0;
i = i++;
printf ("i = %d\n", i);
return 0;
}

какое значение i будет выведенно ?
Nikita is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 17:44   #2
Banned
 
DaNYer's Avatar
 
Join Date: Oct 2002
Location: Brooklyn, New York
Posts: 3,760
Rep Power: 0
Reputation: 10
i=i++ eto kaneshna kruto
DaNYer is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 17:47   #3
»
 
z0mbie's Avatar
 
Join Date: Jan 2002
Posts: 776
Rep Power: 7
Reputation: 10
Send a message via ICQ to z0mbie
0
z0mbie is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 17:49   #4
Banned
 
DaNYer's Avatar
 
Join Date: Oct 2002
Location: Brooklyn, New York
Posts: 3,760
Rep Power: 0
Reputation: 10
rezul'tat i++ vozvrashaet 0. znachit tipa vse v poryadke. a potom etot rezul'tat pripisivaetsya k i. znachit budet 0
DaNYer is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 17:52   #5
Banned
 
DaNYer's Avatar
 
Join Date: Oct 2002
Location: Brooklyn, New York
Posts: 3,760
Rep Power: 0
Reputation: 10
poprobui eshe i=printf("%d", i); ili eshe chego.
DaNYer is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 17:57   #6
»
 
z0mbie's Avatar
 
Join Date: Jan 2002
Posts: 776
Rep Power: 7
Reputation: 10
Send a message via ICQ to z0mbie
btw ас пишется с одним с :]
Attached Images
 
z0mbie is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 17:59   #7
Профессор
 
Nikita's Avatar
 
Join Date: Jan 2005
Location: Perm
Posts: 2,142
Rep Power: 4
Reputation: 10
Send a message via ICQ to Nikita
а можете обьяснить почему ?
Nikita is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 18:05   #8
Banned
 
DaNYer's Avatar
 
Join Date: Oct 2002
Location: Brooklyn, New York
Posts: 3,760
Rep Power: 0
Reputation: 10
ya vrode obyasnil. rezul'tat operacii i++ vozvrashaet 0
DaNYer is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 18:05   #9
»
 
z0mbie's Avatar
 
Join Date: Jan 2002
Posts: 776
Rep Power: 7
Reputation: 10
Send a message via ICQ to z0mbie
потому что приоритет унарного оператора выше чем оператора присвоения
z0mbie is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 18:06   #10
Профессор
 
Nikita's Avatar
 
Join Date: Jan 2005
Location: Perm
Posts: 2,142
Rep Power: 4
Reputation: 10
Send a message via ICQ to Nikita
не обьяснил
Nikita is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 18:14   #11
Banned
 
DaNYer's Avatar
 
Join Date: Oct 2002
Location: Brooklyn, New York
Posts: 3,760
Rep Power: 0
Reputation: 10
imeyushie glaza da uvidyat...
DaNYer is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 18:15   #12
Профессор
 
Nikita's Avatar
 
Join Date: Jan 2005
Location: Perm
Posts: 2,142
Rep Power: 4
Reputation: 10
Send a message via ICQ to Nikita
Danyer
пойми меня правильно
я имею ввиду по стандарту
а не логикой ... твоей логикой
Nikita is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 18:21   #13
Banned
 
DaNYer's Avatar
 
Join Date: Oct 2002
Location: Brooklyn, New York
Posts: 3,760
Rep Power: 0
Reputation: 10
oi, sorry ya ne zametil, dlya accov...

acc eto je latinica... sorry. molchu.

xotya zombie toje neslabo skazal
DaNYer is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 18:23   #14
ЙЦУКЕН
 
Join Date: Jul 2002
Location: 0x68,0x69,0x72, 0x69,0x6e,0x67, 0x20,0x6e,0x6f, 0x77
Posts: 3,113
Rep Power: 7
Reputation: 10
Send a message via ICQ to nm
Quote:
Originally Posted by z0mbie
btw ас пишется с одним с :]
на русском на других языках это может быть не так.
ну извини, какой есть так и формулирует.

а вообще-то постфиксный оператор инкремента(декремента) выполняется _после_ выполнения _всей_ операции в которой он записан.

посему имеем --
i=i;
i++;
что и наблюдаем на экране при выполнении
nm is offline   Reply With Quote Quote selected
Old Apr 22, 2005, 18:29   #15
Профессор
 
Nikita's Avatar
 
Join Date: Jan 2005
Location: Perm
Posts: 2,142
Rep Power: 4
Reputation: 10
Send a message via ICQ to Nikita
я часто делаю ошибки
ну и что ?
Кстате читай беспредел ... там для тебя сообщение ...
Nikita is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
задачка на тему Самолет mk General 186 Dec 23, 2004 16:07
Задачка про пингвина Dorothy General 282 Aug 13, 2004 14:53
Простенькая задачка ;) dolphin Web Development 3 Nov 1, 2003 15:03
Задачка Shirinyan Fun 13 Oct 22, 2003 13:41
Задачка Amph Algorithms 1 May 29, 2002 04:02


All times are GMT. The time now is 00:18.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link