标签: line

C程序来计算注释行(//和/**/)

我需要一个程序来计算.txt或.c文件的行,并返回以下内容:

文件:
简单注释:N行
多行注释:N行
总行数:N行

我有这个:

if (pFile != NULL) 
{
    do { 
    c = fgetc(pFile);

    if (c == '\n') n++;

    } while (c != EOF);
Run Code Online (Sandbox Code Playgroud)

我不知道如何实现其余部分.
我也尝试使用strstr()函数,但也没有得到它.

c comments file count line

-2
推荐指数
1
解决办法
1万
查看次数

如何每行打印x个项目

我打算在这里问这个问题.但是在我做之前我就解决了.我希望能够以更有序的方式打印这个Python 2.7列表.

not_shuffled_deck = ["%i of %s" % (i, s) for i in range(2,10) for s in ('spades', 'diamonds', 'clubs', 'hearts')]

for i in not_shuffled_deck:
    print i + "|",
Run Code Online (Sandbox Code Playgroud)

这就是它最初的结果.

嗯,它实际上比它在这里显示的更糟糕.它取决于控制台大小,屏幕大小,是否有文本换行等.所以在我使用的控制台中,甚至在普通的文本编辑器中,它将以难以阅读的方式显示在多行上.

 2 of spades| 2 of diamonds| 2 of clubs| 2 of hearts| 3 of spades| 3 of diamonds| 3 of clubs| 3 of hearts| 4 of spades| 4 of diamonds| 4 of clubs| 4 of hearts| 5 of spades| 5 of diamonds| 5 of clubs| 5 of hearts| 6 …
Run Code Online (Sandbox Code Playgroud)

python line python-2.7

-2
推荐指数
1
解决办法
1959
查看次数

Python - 打印 line.split 之后的最后一个字符串

有没有一种简单的方法可以在分割后打印最后一个字符串?

输入文件:

Name:DOB:Age 
Name:Name2:DOB:Age
Run Code Online (Sandbox Code Playgroud)

我想要名字和年龄...

所以...

string = line.split(':')
print(string[0] + string[xxxx])
Run Code Online (Sandbox Code Playgroud)

有没有什么东西让 xxxx 总是打印最后一个字符串?

谢谢

python string split line

-2
推荐指数
1
解决办法
2475
查看次数

避免换行并更改字体颜色 CSS

我的 HTML 代码如下所示:

<div class="row">
    <div class="col-md-6 col-sm-6 col-xs-6">
        <section class="widget index">
            <header>
                <h4>
                    <i class="fa fa-bars"></i> Status word <small> </small>
                </h4>
            </header>                                           
            <div class="body">
                - Output A: <div class="dash_data_A"></div>
                - Output B: <div class="dash_data_B"></div>
                - Output C: <div class="dash_data_C"></div>
Run Code Online (Sandbox Code Playgroud)

网站上的显示如下:

- Output A:
false
- Output B:
true
- Output C:
false
Run Code Online (Sandbox Code Playgroud)

第一个愿望:输出值应该在同一行(避免换行),如下所示:

- Output A: false
- Output B: true
- Output C: false
Run Code Online (Sandbox Code Playgroud)

第二个愿望:输出值应该改变false(红色)和 true(绿色)的字体颜色。

我必须在 css 文件中实现它吗?还是在js里?或者两者兼而有之?你有什么建议吗?

css fonts colors line break

-2
推荐指数
1
解决办法
2748
查看次数

最小的平方距离

我有两个有序的x(xcor)和y(ycor)值数组.加入第一个和最后一个点给出一条线.我想计算这条线上所有点的垂直距离.这类似于最小平方距离.有没有直接的方法在matlab中执行此操作?还请注意,距离的符号应代表该线的点的侧面. 在此输入图像描述

 xy =
     -121.9067  -53.5483
     -122.0750  -53.5475
     -122.4750  -53.5243
     -123.0975  -53.4835
     -123.9050  -53.4168
     -124.8050  -53.3235
     -125.7025  -53.2467
     -126.5675  -53.1800
     -127.3825  -53.1215
     -128.1500  -53.0798
     -128.8825  -53.0468
     -129.6000  -53.0452
     -130.3150  -53.1133
     -131.0400  -53.2532
     -131.7850  -53.4513
     -132.5525  -53.6877
     -133.3425  -53.9345
     -134.1600  -54.1758
     -135.0075  -54.4115
     -135.8675  -54.6480
     -136.7375  -54.9040
     -137.5075  -55.2635
     -138.1875  -55.7435
     -138.7775  -56.3333
     -139.2850  -57.0665
     -139.8450  -57.9285
     -140.4550  -58.9492
     -141.1575  -60.0988
     -141.9825  -61.3415
     -142.9275  -62.6172
     -144.0050  -63.8517
     -145.2125  -65.0523
     -146.5450  -66.1715
     -147.9950  -67.1727
     -149.5575  -68.0570
     -151.2225  -68.8152
     -152.9925 …
Run Code Online (Sandbox Code Playgroud)

matlab line points

-2
推荐指数
1
解决办法
155
查看次数

C++ \n 在字符串中(不起作用)

我正在学习C++。这是我的问题。

http://prntscr.com/2m5flm

我创建了一个可以读取像它们一样的 Prop 文件的函数(您可以使用函数设置文件开始和结束标签,使用将返回字符串(包含结果)的函数搜索指定标签。

这是main.cpp

#include <iostream>
#include "m_PFile_r.h"
using namespace std;

int main(int argc, const char * argv[])
{
    m_PFile_r k;
    k.open("prop.arg");
    k.imNotaFag(true);
    k.setOpenArg("$FILE_BEGIN$");
    k.setCloseArg("$FILE_END$");
    string lS;
    lS=k.getArg("launchSentence");
    cout << lS << endl;
    string menu;
    menu=k.getArg("progMenu");
    cout << menu;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我的问题是:为什么它不打印 \n 作为换行符?

谢谢 :)

c++ return line

-3
推荐指数
1
解决办法
3063
查看次数

c错误消息中的行尾错误说丢失; 之后(令牌

# include <stdio.h>
double simpleInterest (double Princ, double Rate, int Time)
{
     double value;
     value = Princ*Rate*Time;
     retrun value;
}
int main (int argc, char * argv [])
{
  printf ("value is £%5.2\n", simpleInterest(100,0.05,1);
  printf ("value is £%5.2\n", simpleInterest(1,0.01,10);
}
Run Code Online (Sandbox Code Playgroud)

我得到一个错误说预期';' 之前')'令牌,但我不明白我已经放了一个; 在每一行之后.我应该把别人放在其他地方吗?

c printf line

-5
推荐指数
1
解决办法
97
查看次数

标签 统计

line ×7

c ×2

python ×2

break ×1

c++ ×1

colors ×1

comments ×1

count ×1

css ×1

file ×1

fonts ×1

matlab ×1

points ×1

printf ×1

python-2.7 ×1

return ×1

split ×1

string ×1