我正在尝试在接受用户输入的Jupyter笔记本中编写一些简单的C代码。一个示例是:
// Problem 7.4
// Write a program that calculates the average of an array of 10 floating-point values.
#include <stdio.h>
int main (void)
{
float values[10] = {0};
for ( int i = 0; i <= 10; i++ )
{
printf("Enter the %ith number: ", i);
scanf("%f", &values[i]);
printf("\n");
}
}
,输出很简单:
Enter the 0th number:
Enter the 1th number:
Enter the 2th number:
Enter the 3th number:
Enter the 4th number:
Enter the 5th number:
Enter the 6th number:
Enter the 7th number:
Enter the 8th number:
Enter the 9th number:
Enter the 10th number:
永远不会给用户输入机会。有没有办法做到这一点Jupyter C内核?
答案 0 :(得分:0)
试试这个。 https://github.com/XaverKlemenschits/jupyter-c-kernel
它说: 通过 scanf 和 getchar 的命令行输入