#include <iostream>
#include <iomanip>
using namespace std;
class A
{
int a;
public:
void set();
int Sum();
int Porduct();
void PrimeNumber();
};
void A::set()
{
cout<<"请输入:"<<endl;
cin>>this->a;
}
int A::Sum()
{
int Sum=0;
for(int i=1;i<=this->a;i++)
{
Sum+=i;
}
return Sum;
};
int A::Porduct()
{
int Por=1;
for(int i=1;i<=this->a;i++)
{
Por*=i;
}
return Por;
};
void A::PrimeNumber()
{
int i;
int j;
for(i=1;i<=this->a;i++)
{
int temp=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
{
temp++;
}
}
if(temp==2)
{
cout<<i<<setw(3);
}
}
cout<<endl;
}
int main()
{
A a1;
a1.set();
cout<<a1.Sum()<<endl;
cout<<a1.Porduct()<<endl;
a1.PrimeNumber();
return 0;
}
#include <iostream>
using namespace std;
class A
{
public:
int a=-1;
void mygetchar();
};
class B
{
public:
char b='a'-1;
void mygetchar();
};
void A::mygetchar()
{
this->a++;
if(this->a<=9)
{
cout<<this->a;
}
if(this->a==9)
{
this->a=-1;
}
}
void B::mygetchar()
{
this->b++;
if(this->b<='z')
{
cout<<this->b;
}
}
int main()
{
A a1;
B b1;
while('z'-b1.b>=10)
{
int i=0;
while(i<=9)
{
a1.mygetchar();
b1.mygetchar();
i++;
}
}
while('z'-b1.b>0)
{
b1.mygetchar();
}
cout<<endl;
return 0;
}
#include <iostream>
#include<cstring>
#include<stdio.h>
using namespace std;
class A{
string a;
public:
void test(char c)
{
a+=c;
}
void show(){
cout<<a<<endl;
}
};
class B{
string b;
public:
void test(char c)
{
b+=c;
}
void show()
{
cout<<b<<endl;
}
public:
};
int main()
{
string str;
A a1;
B b1;
cout<<"请输入字符串"<<endl;
cin>>str;
for(int i=0;i<int(str.length());i++)
{
if(str.at(i)<='z'&&str.at(i)>='a')
{
a1.test(str.at(i));
}else
{
b1.test(str.at(i));
}
}
a1.show();
b1.show();
return 0;
}