小编Nir*_*Geo的帖子

代码的时间复杂度如下?

有人能告诉我下面代码的时间复杂度吗?

#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char a[100]= "Gosh I am confused :D";
int i,count= -1,display_ToVal= strlen(a)-1, display_FromVal;

for( i=strlen(a)-1 ; i>=0 ; i=i+count)
{
        if ( (a[i] == ' ' || i == 0) && count == -1)
        {
         cout << " ";
         display_FromVal = i;
         count = 1;
         if ( i == 0 )
                cout << a[i];
         continue;
        }       

        else if( count == 1 && i == display_ToVal)
        {
         cout << a[i];
         display_ToVal = display_FromVal …
Run Code Online (Sandbox Code Playgroud)

c++ algorithm time-complexity

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

标签 统计

algorithm ×1

c++ ×1

time-complexity ×1