sa se afiseze patratul primelo 90 de nr intrun tabel cu 7 coloane . nr vor fi aliniate la stanga.
Trebuie aranjate putin:
#include <iostream>
using namespace std;
void main()
{
for(int i = 1;i <= 90;i++)
{
cout << i * i << " ";
if(i % 7 ==0)
cout << endl;
}
getchar();
getchar();
}
aty
se citeste n o val intreag poz sa se afiseze nr nat de la 0 la n sep prin spatiu. inainte nr div cu 7 se pune carac *.
#include <iostream>
using namespace std;
int main()
{
int i;
for (i=1;i<=90;i++)
{
if(i<10)
{
cout<<" ";
}
cout<<" "<<i;
if( (i%7)==0 )
{
cout<<"\n";
}
}
cin.ignore();
cin.get();
return 0;
}
patratul :D si pe cloane:-s
Pt. prima intrebare:
Asa e mai aranjat dar nu perfect inca:
#include <iostream>
using namespace std;
void main()
{
for(int i = 1;i <= 90;i++)
{
if(i > 0 && i <= 7)
cout << i * i << " ";
else if(i > 7 && i <= 14)
cout << i * i << " ";
else if(i > 14 && i <= 31)
cout << i * i << " ";
else
cout << i * i << " ";
if(i % 7 ==0)
cout << endl;
}
getchar();
getchar();
}
Last edited on
Si asa e aproape perfect:
#include <iostream>
using namespace std;
void main()
{
for(int i = 1;i <= 90;i++)
{
if(i > 0 && i <= 3)
cout << i * i << " ";
else if(i > 3 && i <= 7)
cout << i * i << " ";
else if(i > 7 && i <= 10)
cout << i * i << " ";
else if(i > 10 && i <= 14)
cout << i * i << " ";
else if(i > 14 && i <= 31)
cout << i * i << " ";
else
cout << i * i << " ";
if(i % 7 ==0)
cout << endl;
}
getchar();
getchar();
}
pt aty
#include <iostream>
using namespace std;
int main()
{
int i,n;
cout<<"introd nr:";
cin>>n;
for (i=1;i<=n; i++)
{
if ( (i%7)==0 )
{
cout<<"*";
}
cout<<i<<" ";
}
cin.ignore();
cin.get();
return 0;
}
PS: metoda lui stefan C. e mai estetica
pt aty:
#include <iostream>
using namespace std;
void main()
{
int n;
cout << "Introduceti n: ";
cin >> n;
for(int i = 0;i <= n;i++)
{
if(i % 7 == 0)
cout << "*" << i << " ";
else
cout << " " << i < " ";
}
getchar();
getchar();
Last edited on
pt mircea
#include <iostream>
using namespace std;
int main()
{
int i;
for (i=1;i<=90;i++)
{
if(i*i<10)
{
cout<<" ";
}
if(i*i<100)
{
cout<<" ";
}
if(i*i<1000)
{
cout<<" ";
}
cout<<" "<<i*i;
if( (i%7)==0 )
{
cout<<"\n";
}
}
cin.ignore();
cin.get();
return 0;
}
ne vedem, bye bye
------------------------
There's more than one way to do it.
#include <iostream>
using namespace std;
int main()
{
int i,n;
cout<<"introduceti nr:";
cin>>n;
cout<<"\n";
for (i=1;i<=n;i++)
{
if(i*i<10)
{
cout<<" ";
}
if(i*i<100)
{
cout<<" ";
}
if(i*i<1000)
{
cout<<" ";
}
if(i*i<10000)
{
cout<<" ";
}
cout<<" "<<i*i;
if ( (i%12)==0 )
{
cout<<"\n";
}
}
cin.ignore();
cin.get();
return 0;
}