用戶輸入若干學生成績
⑴ 編寫一個Java程序,提示用戶輸入學生數量,學生姓名和他們的成績,並按照成績的降序列印學生姓名
你的程序,錯自誤太多了。
1)你name和grade只能保存最後一個輸入的值,不能循環輸入。
2)大概看了一下你的排序,沒有求證,是錯誤的,比如數組會越界。
3)輸出排序後的內容,最後兩句代碼,你將輸出寫在了排序的代碼里,排序還沒有排好,輸出的不可能正確。
.....
最嚴重的就是第一條了,你得看看Java的標准輸入輸出。
⑵ C++,處理任意人數的學生成績,學生成績利用一維數組保存,人數由用戶輸入
#include<iostream>
using namespace std;
int main(){
int n;
cout<<"Input the number of students:";
cin>>n;
int *score;
score=new int[n];
double sum=0;
cout<<"Input students' scores:"<<endl;
for(int i=0;i<n;i++){
cin>>score[i];
sum+=score[i];
}
double avg=sum/n;
cout<<"The average of students' scores:"<<avg<<endl;
delete []score;
return 0;
}
⑶ c++用戶輸入若干學生的成績,當輸入的數值為0時,說明成績已經全部輸入,然後輸出總成績和平均成績
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int score; // 分數
int sum = 0; // 總成績
int ave = 0; // 平均成績
int cnt = 0; // 學生數
while(cin >> score && score != 0)
{
sum += score;
cnt++;
}
cout << "總成績:" << sum << endl;
cout << "平均成績:" << (sum / cnt) << endl;
return 0;
}
望採納
⑷ C語言的編程 1.由用戶從鍵盤輸入8個學生的成績,利用單精度類型的一維數組存放8個學生的成績值。
#include<stdio.h>
#include<conio.h>
#include<math.h>
int Max,Min;
void main()
{
float ave,score(int array[]);
int i,a[10];
printf("請輸入數組元素:\n");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
printf("\n");
ave=score(a);
printf("最高分=%d\n最低分=%d\n平均分=%f\n",Max,Min,ave);
getch();
}
float score(int array[])
{
int i;
float Sum=0.0;
float Aver;
Max=array[0];
Min=array[0];
for(i=1;i<8;i++)
{
Sum=Sum+array[i];
if(array[i] >= Max)
Max=array[i];
if(array[i] <= Min)
Min=array[i];
}
Aver=Sum/8;
return(Aver);
}
⑸ 編寫一個程序,提示用戶輸入學生個數,學生姓名和他們的成績,然後按照學生成績的降序列印學生成績的排行榜.
import java.util.Arrays;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
reader = new Scanner(System.in);
System.out.println("請輸入學生個數");
String strStuNum = reader.nextLine();
int stuNum = Integer.parseInt(strStuNum);
String[] sNames = new String[stuNum];
int[] sScore = new int[stuNum];
for(int i = 0;i < stuNum; i++){
System.out.println("請輸入第"+(i+1)+"個學生的姓名");
sNames[i] = reader.nextLine();
System.out.println("請輸入"+sNames[i]+"的分數");
sScore[i] = Integer.parseInt(reader.nextLine());
}
int tempScore;
String tempName;
for (int i = stuNum - 1; i > 0; --i) {
boolean isSort=false;
for (int j = 0; j < i; ++j) {
if (sScore[j + 1] < sScore[j]) {
tempScore = sScore[j];
tempName = sNames[j];
sScore[j] = sScore[j + 1];
sNames[j] = sNames[j + 1];
sScore[j + 1] = tempScore;
sNames[j + 1] = tempName;
isSort=true;
}
}
if(!isSort)break;
}
for(int i = stuNum - 1; i >= 0;i--){
System.out.println("第"+(stuNum - i)+"名\t"+sNames[i]+"\t"+sScore[i]);
}
}
}
⑹ access中,基於學生成績表,根據用戶輸入的姓氏查詢學生各科成績,用查詢設計怎麼做
SELECT學生成績.*
FROM學生成績
WHERE(((學生成績.姓名)Like[請輸入學生姓氏]&"*"));
查詢設計視圖
⑺ 有若干個學生的成績(每個學生有4門課程),要求在用戶輸入學生的序號後,能輸出干學生的全部成績。
根據學生的序號做一次查詢,再顯示就可以了。你那數據是不是存資料庫?就是用資料庫查詢,select * from你的表名where序號=?
⑻ C語言題目:要求用戶輸入10個學生的考試成績,並編寫一個求平均值的函數,求這10個學生的平均成績。
#include"stdio.h"
int ave(int m[12])
{
int i,zongh=m[1];
for (i=2;i<11;i++)
zongh=zongh+m[i];
return (zongh/10);
}
main()
{ int i,chengji[12],pingjun;
printf("請輸入10名學生的成績\n");
for(i=1;i<11;i++)
{
printf("請輸入第%d個學生的成績:",i);
scanf("%d",&chengji[i]);
}
pingjun=ave(chengji);
printf("%d",pingjun);
}
⑼ 編寫程序,用戶輸入10個學生的成績信息,包括學號,姓名,英語成績,數學成績和計算機成績
很簡單啊
#include <stdio.h>
#incluude <fstream>
#include <iostream>
#include<string>
using namespace std;
void find(ofstream &fp, char * szKey)
{
ifstream in("grades.txt");
if(!in)
{
cerr << "some errors happened";
return -1;
}
string str;
while(getline(in, str))
{
if(-1!=str.find_first_of(szKey))
{
cout << str << endl;
break;
}
}
return 0;
}
void append(ofstream &fp)
{
char szNo[16];
char szName[10];
float fEnglish, fMath, fComputer;
//輸入中間用空格間隔
scanf("%s %s %f %f %f\n",szNo, szName, &fEnglish, &fMath, &fComputer);
fp << szNo << szName << fEnglish << fMath << fComputer<<endl;
}
int main()
{
ofstream resulttxt;
resulttxt.open("grades.txt", ios_base::out | ios_base::app);
resulttxt << "學號||" << "姓名||" << "英語成績||" << "數學成績||" << "計算機成績"<<endl;
for(int i = 0; i < 10; i++)
{
append(resulttxt);
}
resulttxt.close();
return 0;
}
⑽ 接收用戶輸入的學生成績,直到用戶輸入-1時循環結束
int main()
{
int a;
cout << "請輸入學生成績:";
cin >> a;
while (a != -1)
{
cout << "請輸入學生成績:";
cin >> a;
}