计算字符串的打印次数

时间:2014-06-02 13:53:22

标签: java

我有一个多次打印字符串的for循环。

我需要知道:

如何获取字符串的打印次数?

谢谢!

1 个答案:

答案 0 :(得分:3)

int count = 0

for (int i = 0 ; i < stop_criteria; i++){
    // print string
    count++;
}
printf("Number of times printed %d", count);

TheLostMind建议:

int i;
for (i = 0 ; i < stop_criteria; i++){
    // print string
}

printf("Number of times printed %d", i);