T7.1
#include <iostream>
using namespace std;
int main()
{
int lower,upper;
cin>>lower>>upper;
if(lower > upper || upper > 100 || lower <=0)
{
cout<<"Invalid.";
return 0;
}
cout<<"fahr celsius"<<endl;
for(int i = lower;i<=upper;i+=2)
{
printf("%d%6.1lf\n",i, 5.0 * (i - 32.0)/9.0);
}
}
T7.2
#include <iostream>
using namespace std;
int main()
{
int N;
cin>> N;
double sum = 0;
for(int i = 1; i<= N; i++)
sum+= 1.0 / i;
printf("sum = %.6lf",sum);
}
T7.3
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
double sum = 0;
for(int i = 1; i<= N*2 ; i += 2)
sum += 1.0 / i;
printf("sum = %.6lf",sum);
}
T7.4
#include <iostream>
using namespace std;
int main()
{
int N;
cin>> N;
double sum = 0;
for(int i = 1; i <= N ; i++)
{
if( (i & 1) == 1)
sum += (1.0 / (i * 3 -2));
else
sum -= (1.0 / (i * 3 -2));
}
printf("sum = %.3lf",sum);
}
T7.5
#include <iostream>
using namespace std;
int main()
{
int m,n;
cin>>m>>n;
double sum =0;
for(int i=m;i<=n;i++)
{
sum += i*i + 1.0/i;
}
printf("sum = %.6lf",sum);
}
T7.6
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
double sum = 0;
for(int i = 1;i<=N;i++)
{
if ( (i & 1) == 1)
sum += i / ( 2*i -1.0);
else
sum -= i / ( 2 *i -1.0);
}
printf("%.3lf",sum);
}
T7.7
#include <iostream>
using namespace std;
int main()
{
double esp;
cin>> esp;
int cur = 1;
double sum =0;
do{
if( (cur & 1) == 1)
sum+=1.0/(cur * 3.0 -2.0);
else
sum-=1.0/(cur * 3.0 -2.0);
cur++;
} while(1.0/(cur * 3.0 -2.0) >= esp);
printf("sum = %.6lf",sum);
}
T7.8
#include <iostream>
using namespace std;
int main()
{
int a,N;
cin>>a>>N;
int count = 0;
while(N--)
{
count ++;
int n;
cin>>n;
if(n < 0)
break;
if(n > a)
cout<<"Too big"<<endl;
else if(n<a)
cout<<"Too small"<<endl;
else
{
if(count == 1)
cout<<"Bingo!"<<endl;
else if(count <=3)
cout<<"Lucky You!"<<endl;
else
cout<<"Good Guess!"<<endl;
return 0;
}
}
cout<<"Game Over"<<endl;
}
T7.9
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
double sum =1 ;
double gamma = 1;
for(int i = 1;i <=n ; i++)
{
gamma *= i;
sum += 1.0 / gamma;
}
printf("%.8lf",sum);
}
T7.10
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int minn;
cin>>minn;
while(--n)
{
int num;
cin>>num;
minn = min(minn,num);
}
cout<<"min = "<<minn;
}
标签:23,int,sum,namespace,cin,强基班,using,习题,main
From: https://www.cnblogs.com/Icys/p/18103898