#include<stdio.h>
#include<conio.h>
#define PROD(x) (x*x)
void main()
{
clrscr();
int p=3,k;
k=PROD(p+1); //here i think value 3+1=4 would be passed to macro
printf("\n%d",k);
getch();
}
Run Code Online (Sandbox Code Playgroud)
在我看来,输出应该是16
,但我明白了7
.
谁能告诉我为什么?
int j=5,k=9;
printf("%d...%d");
Run Code Online (Sandbox Code Playgroud)
这个问题出现在一本书中.给出的输出:5 9但是当我尝试这个时我得到了:垃圾值,请向我解释一下.书中的解释说printf取得了程序前两个赋值的值
#include<iostream>
#include<string>
using namespace std;
int main()
{
int i;
cout<<"enter ur no. plz";
cin>>i;
cout<<"ur no. is:"<<i;
cin.get();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
此代码未显示我输入的整数.它在输入一个整数并返回后返回.我正在使用开发C++.
#include<stdio.h>
#include<conio.h>
#define SQUARE(x) (x*x)
void main()
{
clrscr();
int i=3,j,k;
j=SQUARE(i++);
k=SQUARE(++i);
printf("\n%d\n%d\n%d",j,k,i);
getch();
}
Run Code Online (Sandbox Code Playgroud)
答案令人困惑:9 49 7我在想j = 3*4 = 12,k = 6*7 = 42,i = 7发生了什么事?我错过了什么吗?(x*x)=((x)*(x))这里相同.没关系.
#include<stdio.h>
#include<conio.h>
int t=8;
int dok(int);
int doky(int);
int main()
{
int clrscr();
int x,y;
int s=2;
s*=3;
x=dok(s);
y=doky(s);
printf("%d%d%d",s,y,x);
getch();
return 0;
}
int dok(int a)
{
a+=-5;
t-=4;
return(a+t);
}
int doky(int a)
{
a=1;
t+=a;
return(a+t);
}
Run Code Online (Sandbox Code Playgroud)
回答上述代码:665
我明白为什么s=6
,x=1+4=5
(a=6-5=1
,t=8-4=4
)...请告诉我如何y
正值6
,我以为y
会是1+4=5
(a=1
,t=4
)
谢谢,请帮帮我.