c语言中(x,y)中怎么计算

Python025

c语言中(x,y)中怎么计算,第1张

(x,y) 是逗号表达式,逗号表达式的值等于 最右边 那个表达式的值。

所以 (x,y) 的结果 是 y.

例如:

#include <stdio.h>

main(){

int x=1,y=2

printf("%d",(x,y))

return 0

}

输出结果 是 y 的当前值: 2

不知道你说的是那种:

如果直接是int x,y;的话那就是整型变量;

如果是函数比如:max(int x,int y)的话是整型形参

如果是#define x x=500x是宏定义;

用ReadConsoleOutputCharacterA函数,在windows.h中。

给你一个封好的函数吧,其作用是提取出窗口中第x行y列的位置的字符是什么。(如果没有东西会返回空格符号)。

#include<windows.h>

//下标从1开始,x行y列。

char GetStr(int x, int y)

{

COORD pos

//ReadConsoleOutputCharacterA里的x和y指的是x列y行,且从0开始标号 

pos.X = y-1pos.Y = x-1

LPSTR str

DWORD read

ReadConsoleOutputCharacterA(GetStdHandle(STD_OUTPUT_HANDLE), str, 1, pos, &read)

return str[0]

}

使用举例:

int main()

{

printf("kjndfgdfg\nkhgfhfhfgd\njifdgdfgg\n")

printf("1,2:%c\n",GetStr(1,2))

return 0

}

输出为

kjndfgdfg

khgfhfhfgd

jifdgdfgg

1,2:j