我正在从一本书中自学C,我正在尝试创建一个填字游戏.我需要创建一个字符串数组但仍然遇到问题.另外,我对阵列不太了解......
这是代码片段:
char word1 [6] ="fluffy", word2[5]="small",word3[5]="bunny";
char words_array[3]; /*This is my array*/
char *first_slot = &words_array[0]; /*I've made a pointer to the first slot of words*/
words_array[0]=word1; /*(line 20)Trying to put the word 'fluffy' into the fist slot of the array*/
Run Code Online (Sandbox Code Playgroud)
但我不断收到消息:
crossword.c:20:16: warning: assignment makes integer from pointer without a cast [enabled by default]
Run Code Online (Sandbox Code Playgroud)
不确定是什么问题...我试图查找如何制作一个字符串数组但没有运气
任何帮助都感激不尽,
山姆
我试图在其垂直轴上翻转图片,我在python中执行此操作,并使用Media模块.
像这样:

我试图找到原始和翻转之间的关系.因为我不能去python中的负坐标,我决定做的是使用图片的中间作为参考.
所以我将图片分成两半,这就是我要做的事情:
[注意我创建一个新的空白图片并将每个(x,y)像素复制到对应于(-x,y),如果原始像素在中间之后.
如果它在中间之前,我将像素(-x,y)复制到(x,y)

所以我在python中编码,这就是结果.
原版的:

我懂了:
import media
pic=media.load_picture(media.choose_file())
height=media.get_height(pic)
width=media.get_width(pic)
new_pic=media.create_picture(width,height)
for pixel in pic:
x_org=media.get_x(pixel)
y_org=media.get_y(pixel)
colour=media.get_color(pixel)
new_pixel_0=media.get_pixel(new_pic,x_org+mid_width,y_org) #replace with suggested
#answer below
media.set_color( new_pixel_0,colour)
media.show(new_pic)
Run Code Online (Sandbox Code Playgroud)

这不是我想要的,但我很困惑,我试图找到原始像素位置与其变换(x,y) - >( - x,y)之间的关系.但我认为那是错的.如果有人能用这种方法帮助我,那就太棒了.
在一天结束时,我想要一张这样的照片:

http://www.misterteacher.com/alphabetgeometry/transformations.html#Flip
我试图在Python中实现一个队列.但是每次我运行我的代码时,我都会收到消息"AttributeError:Queue实例没有属性'队列'"我已经挣扎了一个多小时左右.非常感谢任何帮助.
我的代码:
class Queue:
def __int__(self):
'''initilize a empty queue'''
self.queue = []
def dequeue(self):
'''remove and return the last element'''
return self.queue.pop()
def enqueue(self, val):
'''Add element to the end'''
self.queue.append(val)
def is_empty(self):
'''Return True if empty queue'''
return len(self.queue) == 0
if __name__== '__main__':
q = Queue()
for i in range(0,11):
q.enqueue(i)
while not q.is_empty():
print q.dequeue()
Run Code Online (Sandbox Code Playgroud) 在C中,我试图从main调用函数printSum.但主要功能是不调用printSum,它只打印出"嗨!" 这是来自main的打印声明.我不确定为什么没有调用printSum.谢谢.
码:
int main(void){
void printSum(void);
printf("Hi!\n");
return 0;
}
void printSum (void){
printf("Please give two integers\n");
int x,y;
scanf("%d %d", &x,&y);
printf("%d + %d is %d\n",x,y,x+y);
}
Run Code Online (Sandbox Code Playgroud)
山姆