Jump to content


Photo

idee de algoritm care arata num. de la 1-100 scris pe telefon


  • This topic is locked This topic is locked
2 replies to this topic

#1
kalfanyy

kalfanyy

    -

  • Posts
    2,137
  • Topics
    44
  • Reputation
    97
  • Online
    10 days
#include <iostream.h>
using namespace std;

int main()
{
int n = 100 = i; // 100 nr. maxim la care sa ajunga numaratoarea
for (i = 0; i<100; i++) // aceeasi poveste pt 100
int prim = 0;
{
for int (j = 2; j<i / 2 = j++)
{
if (i % j ! = 0) { prim++; }
if (prim != 0) cout << i; }
return 0; }
  • 0

#2
neacristy

neacristy

    Backend Developer

  • Posts
    2,736
  • Topics
    615
  • Reputation
    1712
  • Online
    118 days

daca ai pus iostream.h nu mai pui using namespace std;

 

#include <iostream>

 

using namespace std;

 

int main()

{ int n = 100;

  while(n) cout << n << '\n', --n;

  return 0;

}

 

sau

#include <iostream>

 

using namespace std;

 

int main()

{ int n = 100, i = 1;

  while(i <= n) cout << i << '\n', ++i;

  return 0;

}

Apropo, codul tau e scris gresit.


  • 2

#3
kalfanyy

kalfanyy

    -

  • Posts
    2,137
  • Topics
    44
  • Reputation
    97
  • Online
    10 days

daca ai pus iostream.h nu mai pui using namespace std;

 

#include <iostream>

 

using namespace std;

 

int main()

{ int n = 100;

  while(n) cout << n << '\n', --n;

  return 0;

}

 

sau

#include <iostream>

 

using namespace std;

 

int main()

{ int n = 100, i = 1;

  while(i <= n) cout << i << '\n', ++i;

  return 0;

}

Apropo, codul tau e scris gresit.

bc001395ad5fdb98378b5d7a65fbe926.png

ec60c3cf75663f902d73ba870a48deaf.png


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users