❶ C語言編程題 獎學金
#include <iostream>
#include <math>
using namespace std;
void printAward(int value1, int value2, int value3)
{
if(value1 >= 90 && value2 >= 90 && value3 >= 90)
{
cout<<"等級1";
}
else if(value1 >=80&& value2 >= 80 && value3 >= 80)
{
cout<<"等級2";
}
else
{
int minVal = min(min(value1, value2), min(value2, value3));
int maxVal = max(max(value1, value2), max(value2, value3));
int midVal = value1 + value2 + value3 - minVal - maxVal;
if(midVal >= 90 && minVal >= 70)
{
cout<<"等級2";
}
else
{
cout<<"無獎學金";
}
}
}
void main()
{
int value1, value2, value3;
cin>>value1>>value2>>value3;
printAward(value1, value2, value3);
}
❷ C語言獎學金
#include<stdio.h>
#include<stdlib.h>
typedefstructStudent{
intsnum;
charscore[10];
intsum;
}Student;
intmain(){
intn;
scanf("%d",&n);
Studenta[128];
inti,j;
for(i=0;i<n;i++){
a[i].snum=i+1;
a[i].sum=0;
for(j=0;j<3;j++){
scanf("%d",&a[i].score[j]);
a[i].sum+=a[i].score[j];
}
}
Studenttmp;
for(j=n-1;j>0;j--){
for(i=0;i<j;i++){
if(a[i].sum<a[i+1].sum){
tmp=a[i];
a[i]=a[i+1];
a[i+1]=tmp;
}
elseif(a[i].sum==a[i+1].sum){
if(a[i].score[0]<a[i+1].score[0]){
tmp=a[i];
a[i]=a[i+1];
a[i+1]=tmp;
}
}
}
}
for(i=0;i<5;i++){
printf("%d%d ",a[i].snum,a[i].sum);
}
system("pause");
return0;
}
❸ 用C語言編一個程序,計算學生獎學金的等級,以三門功課成績M1,M2,M3為評獎依據。獎學金評定標准如下:
char panding(float M1, float M2, float M3)
{
char res;
if(M1 + M2 + M3 >95*3)
{
res ='A';
}
else if(M1 ==100 & M2 ==100 &M3>=80)
{
res ='A';
}
else if(M1 ==100 & M3 ==100 &M2>=80)
{
res ='A';
}
else if(M2 ==100 & M3 ==100 &M1>=80)
{
res ='A'弊爛;
}
else if(M1+M2+M3>90*3)
{
res ='B';
}
else if(M1==100 & M2>75 & M3>75)
{
res ='B';
}
else if(M2==100 & M1>75 & M3>75)
{
res ='B'歲敗;
}
else if(M3==100 & M1>75 & M2>75)
{
res ='B';
}
else if(M1>75 & M2>乎卜顫75 & M3>75)
{
res ='C';
}
else
{
res ='0';
}
return res;
}