码:
printf("Enter your data (5x10) of characters: \n");
for (i = 0; i < SIZE1; i++)
for (j = 0; j < SIZE2; j++)
scanf("%c", &matrix2[i][j]);
compress(matrix2);
break;
Run Code Online (Sandbox Code Playgroud)
我的代码假设采用5 x 10char矩阵.但是目前我的换行符正在输入到矩阵中,我如何实际检查换行符,并防止它进入matrix2[i][j]?
它总共读取了4个换行符.输入:
aaabbbcccd (press enter)
ababababab (press enter)
bcdbcdbcdb (press enter)
ababababab (press enter)
abbbcccdda
Run Code Online (Sandbox Code Playgroud) 我有一个递归函数,我想计算其中的零数,如何使用常量来计算零,不允许重置.
int countZeros(int num)
{
int count = 0;
if (num > 0)
{
if (num % 10 == 0)
count++;
return(countZeros(num / 10));
}
if (num <= 0)
return count;
}
Run Code Online (Sandbox Code Playgroud)
对于我的代码,我的计数将在调用返回函数后重置.有没有办法防止这种情况发生?我必须将值返回到我的main函数并从那里显示.
case 9:
printf("Enter a number: ");
scanf("%d", &recursion);
printf("number of zeros = %d",countZeros(recursion));
break;
Run Code Online (Sandbox Code Playgroud) 我有一个数据框,其中包含各种变量和一个包含向量的特定列。是否有一些代码可以将值替换为列中找到的第一个向量?
| ID | 费用 |
|---|---|
| 1 | c(420,700) |
| 2 | 400 |
| 3 | c(200,720) |
所需的输出:
| ID | 费用 |
|---|---|
| 1 | 第420章 |
| 2 | 400 |
| 3 | 200 |
我尝试在 Rshiny 中使用 ggstats 绘制箱提琴图。我收到错误无法转换为符号。尽管我已经将输入作为符号传递,但我仍然面临这个错误。数据表没有问题,因为我尝试从 Rshiny 中绘制它并且它有效。有人知道为什么吗?
用户界面
library (ggstatsplot)
library (shiny)
total_data <- read_rds('data/total_data.rds')
ui <- fluidPage(
# Application title
titlePanel("Trial"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
selectInput(inputId = "Weekday",
label = "Choose a Weekday Type",
choices = c( "Weekday Earnings" = "weekday_earn",
"Weekend Earnings" = "weekend_earn",
"Total Earnings" = "total_earn"
),
selected = "total_earn")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
Run Code Online (Sandbox Code Playgroud)
输出
server …Run Code Online (Sandbox Code Playgroud)