C
#include
int main()
{
int a, b, c,m;
scanf_s("%d%d%d", &a, &b,&c);
m = a;
if (b > m)
m = b;
if (c > m)
m = c;
printf("max number is %d", m);
return 0;
}
C++
#include
using namespace std;
int main() {
int a, b, c, m;
cin >> a >> b >> c;
cout << a << endl;
cout << b << endl;
cout << "the meaning of c =" << c << endl;
m = a;
if (b > m)
m = b;
if (c > m)
m = c;
cout << m<<endl;
}
C
#include
#include
int main()
{
double a, b, c, d, x1, x2;
printf( "请输入一元二次方程a,b,c对应的值,用空格隔开\n");
scanf_s("%5lf%5lf%5lf", &a, &b, &c);
printf ( "a=%5lf,b=%5lf,c=%5lf\n",a,b,c);
if (a == 0 & b == 0)
{
printf( "方程无解\n");
return 0;
}
if (a == 0)
{
printf("x的值是%5lf\n", -c / b );
return 0;
}
d = b * b - 4 * a * c;
if (d < 0)
{
printf("方程无解\n");
return 0;
}
if (d == 0)
{
x1 = (-b) / (2 * a);
printf("x1=x2,他们的值是%5lf\n", x1);
return 0;
}
if (d > 0)
{
x1 = (-b + sqrt(d)) / (2 * a);
x2 = (-b - sqrt(d)) / (2 * a);
printf("x1,x2,他们的值是x1=%5lf,x2=%5lf\n", x1,x2);
return 0;
}
}
C++
#include
using namespace std;
#include
int main()
{
double a, b, c,d,x1,x2;
cout << "请输入一元二次方程a,b,c对应的值,用空格隔开"<<endl;
cin >> a >>b >> c;
cout << "a=" << a << ",b=" << b << ",c=" << c << endl;
if (a == 0 and b == 0)
{
cout << "方程无解" << endl;
return 0;
}
if (a == 0)
{
cout << "x的值是" << -c / b << endl;
return 0;
}
d = b * b - 4 * a*c;
if (d<0)
{
cout << "方程无解" << endl;
return 0;
}
if (d==0)
{
x1 = (-b) / (2 * a);
cout << "x1=x2=" <<x1 << endl;
return 0;
}
if(d>0)
{
x1 = (-b + sqrt(d)) / (2 * a);
x2 = (-b - sqrt(d)) / (2 * a);
cout << "x1=" << x1<< ",x2="<<x2 << endl;
return 0;
}
}
C
#include
int main()
{
printf("请输入您的成绩,回车结束\n");
int grade;
scanf_s("%d", &grade);
if (grade >=90) printf("您的等级是A");
else if (grade >= 60) printf("您的等级是B");
else printf("您的等级是C");
}
C++
#include
using namespace std;
int main()
{
cout << "请输入您的成绩,分数在0-100 之间的整数,回车结束"<<endl;
int grade;
cin >> grade;
if (grade >= 90) cout << "您的等级是A";
else if (grade >= 60) cout << "您的等级是B";
else cout << "您的等级是C";
}
C
#include
int main()
{
double a, b, c;
printf( "请输入三角形的三条边,以空格分隔,回车结束\n");
scanf_s("%5lf%5lf%5lf", &a, &b, &c);
if ((a + b) > c and (a + c) > b and (b + c) > a)
printf( "可以组成三角形");
else
printf( "不可以组成三角形");
}
C++
#include
using namespace std;
int main()
{
double a, b, c;
cout << "请输入三角形的三条边,以空格分隔,回车结束"<<endl;
cin >> a >> b >> c;
if ((a + b) > c and (a + c) > b and (b + c) > a)
cout << "可以组成三角形";
else
cout << "不可以组成三角形";
}
C
#include
int main()
{
double total;
int minnumber, maxnumber, a;
printf( "请输入20个数字,以回车结束" );
scanf_s("%d",&a);
total = minnumber = maxnumber = a;
for (int i = 1; i < 20; i++)
{
scanf_s("%d", &a);
if (maxnumber < a)
{
maxnumber = a;
}
if (minnumber > a)
minnumber = a;
total = total + a;
}
printf("最大值是:%d\n",maxnumber);
printf("最小值是:%d\n", minnumber);
printf("平均值是%3lf",total/20);
}
C++
#include
using namespace std;
int main()
{
double a, minnumber, maxnumber, total;
cout << "请输入20个数字,以回车结束" << endl;
cin >> a;
total = minnumber = maxnumber = a;
for(int i=1; i<20;i++)
{
cin >> a;
if (maxnumber<a)
{
maxnumber = a;
}
if (minnumber > a)
minnumber = a;
total = total + a;
}
cout << "最大值是:" << maxnumber<<endl;
cout << "最小值是:" << minnumber << endl;
cout << "平均值是:" << total / 20;
}
C
#include
int main()
{
int n, a, maxnumber, minnumber, total;
printf("请输入要计算数字的个数 和数字,用空格分开\n");
scanf_s("%d", &n);
scanf_s("%d" ,& a);
maxnumber = minnumber = total = a;
for (int i = 1; i < n; i++)
{
scanf_s("%d", &a);
if (a > maxnumber)
maxnumber = a;
if (a < minnumber)
minnumber = a;
total += a;
}
float d;
d = total / n;
printf( "平均值为%3lf\n",d);
printf("最大值为%d\n", maxnumber);
printf("最小值为%d\n", minnumber);
}
C++
#include
using namespace std;
int main()
{
int n, a, maxnumber, minnumber,total;
cout << "请输入要计算数字的个数" << endl;
cin >> n;
cin >> a;
maxnumber = minnumber = total = a;
for(int i=1;i<n;i++)
{
cin >> a;
if (a > maxnumber)
maxnumber = a;
if (a < minnumber)
minnumber = a;
total += a;
}
cout << "最大值为" << maxnumber << endl;
cout << "最小值为" << minnumber << endl;
double d;
d = total / n;
cout << "平均值为" << d<<endl;
}
C
#include
int main()
{
int a, maxnumber, total;
int n = 1;
printf( "输入若干个数,输入 -999表示结束" );
scanf_s("%d",&a);
maxnumber = a;
total = 0;
while (a != -999)
{
if (a > maxnumber)
maxnumber = a;
total += a;
n = n + 1;
scanf_s("%d", &a);
}
printf("最大值为:%d", maxnumber);
float d = total / n;
printf( "平均值为%3lf",d);
return 0;
}
C++`
using namespace std;
int main()
{
int a,maxnumber, total;
int n = 1;
cout << "输入若干个数,输入 -999表示结束"<<endl;
cin >> a;
maxnumber = a;
total = 0;
while(a!=-999)
{
if (a > maxnumber)
maxnumber = a;
total += a;
cout << "total=" << total << endl;
n = n + 1;
cin >> a;
}
cout << "最大值为:" << maxnumber<<endl;
cout << "平均值为:" << total / n;
return 0;
}
C
#include
int main()
{
int sum = 0, temp;
for (int i = 1; i <= 100; i++)
{
temp = i * i;
sum += temp;
}
printf("1-100平方的和为%d",sum);
}
C++
#include
using namespace std;
int main()
{
int sum=0,temp;
for (int i = 1; i <= 100; i++)
{
temp = i * i;
sum += temp;
}
cout << "1-100平方的和为" << sum;
return 0;
}
C
#include
int main()
{
double sum = 1, temp = 1;
for (int i = 1; i < 64; i++)
{
temp = temp * 2;
sum = sum + temp;
}
printf("%lf", sum);
return 0;
}
C++
#include
using namespace std;
int main()
{
double sum = 1,temp=1;
for(int i=1;i<64;i++ )
{
temp = temp * 2;
sum = sum + temp;
}
cout << sum << endl;
return 0;
}
C
#include
int main()
{
double sum = 1, temp = 1;
for (int i = 1; i < 64; i++)
{
temp = temp * 2;
sum = sum + temp;
}
printf("%9lf", sum);
return 0;
}
C++
#include
using namespace std;
int main()
{
double sum = 1,temp=1;
for(int i=1;i<64;i++ )
{
temp = temp * 2;
sum = sum + temp;
}
cout << sum << endl;
return 0;
}