A. 利用c語言設計簡單的小學生算術自測系統,求大神編寫程序
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define NUMBER 10/*定義數組項目的個數為一個符號常量*/
int Num1[10]= {0},Num2[10]= {0},Pos1=0,Pos2=0;
/*定義兩個數組來保存已經出現的情況*/
int main()
{
int putquestion();/*聲明出題函數*/
int questionnum=10;/*聲明變數*/
int i=1;
printf("Please input number of question:");
scanf("%d",&questionnum);
int answer[NUMBER];/*聲明一個數組,用於儲存學生的答案*/
int rightanswer[NUMBER];/*聲明一個數組,用於儲存正確答案*/
for(i=1; i<=questionnum; i++)
{
rightanswer[i-1]=putquestion();
scanf("%d",&answer[i-1]);
}
for(i=1; i<=NUMBER; i++)
printf("\n%d%5d",answer[i-1],rightanswer[i-1]);
}
bool exist(int goal,int *Num)
{/*檢查數字goal是否已經出現在Num數組裡面*/
int i;
for(i=0; i<Pos1; i++)
if(goal==Num[i])
return true;
return false;
}
int putquestion()/*此函數用於出題*/
{
int randValue;
int num1;
int num2;
int correctanswer;
srand((int)time(NULL));
randValue=1+rand()%4;
num1=1+rand()%99;
num2=1+rand()%99;
switch(randValue)
{
case 1:/*加法作業*/
while(num1+num2>=100||exist(num1,Num1)&&exist(num2,Num2))
{/*當滿足該條件(滿足題目要求且兩個數同時出現過)時繼續循環*/
num1=1+rand()%99;
num2=1+rand()%99;
}
Num1[Pos1++]=num1;
Num2[Pos2++]=num2;
printf("\n%d+%d=",num1,num2);
correctanswer=num1+num2;
break;
case 2:/*減法作業*/
while(num1-num2<0||exist(num1,Num1)&&exist(num2,Num2))
{
num1=1+rand()%99;
num2=1+rand()%99;
}
Num1[Pos1++]=num1;
Num2[Pos2++]=num2;
printf("\n%d-%d=",num1,num2);
correctanswer=num1-num2;
break;
case 3:/*乘法作業*/
while(num1*num2>=100||exist(num1,Num1)&&exist(num2,Num2))
{
num1=1+rand()%99;
num2=1+rand()%99;
}
Num1[Pos1++]=num1;
Num2[Pos2++]=num2;
printf("\n%d*%d=",num1,num2);
correctanswer=num1*num2;
break;
case 4:/*除法作業*/
while(num1%num2!=0||exist(num1,Num1)&&exist(num2,Num2))
{
num1=1+rand()%99;
num2=1+rand()%99;
}
Num1[Pos1++]=num1;
Num2[Pos2++]=num2;
printf("\n%d/%d=",num1,num2);
correctanswer=num1/num2;
break;
}
return(correctanswer);
}
B. C語言,設計一個程序幫助小學生練習數學。
1L的哥們竟然沒有分數也沒有讀寫文件記錄,我在他的基礎上加了這個功能,採納誰都可以哦~
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <windows.h>
#define IDNO_LENGTH 6
#define CALC_KIND 4
#define CALC_NUM 10
bool checkNo(char idNo[]);
char getSignal();
int getResult(int,int,char);
void takeTest();
//main函數
void main()
{
printf("Please input your four digit ID no(begin with two letters):");
char idNo[IDNO_LENGTH];
do
{
scanf("%s",&idNo);
fflush(stdin);
} while(checkNo(idNo)==false);
printf("1.Start a test\t2.Check score\t3.Exitb\n");
int choose;
do
{
printf("選擇:");
scanf("%d",&choose);
fflush(stdin);
} while(choose!=1 && choose!=2&& choose!=3);
if(choose==1)
{
takeTest();
}else if(choose==2)
{
FILE *fp;
char ch;
if((fp=fopen("score.txt","rt+"))==NULL)
{
printf("\n你還沒做過題目測試");
getch();
exit(1);
}
ch=fgetc(fp);
while(ch!=EOF)
{
putchar(ch);
ch=fgetc(fp);
}
fclose(fp);
}
else
{
exit(0);
}
}
//獲取隨機運算符
char getSignal()
{
char signal[CALC_KIND]={'+','-','*','/'};
srand((unsigned)time(NULL));
return signal[rand()%4];
}
//獲取隨機數
int random(double start, double end)
{
return (int)(start+(end-start)*rand()/(RAND_MAX+ 1.0));
}
//運算
int getResult(int num1,int num2,char signal)
{
int res;
switch(signal)
{
case '+':
res=num1+num2;break;
case '-':
res=num1-num2;break;
case '*':
res=num1*num2;break;
case '/':
res=num1/num2;break;
default:
res=0;
printf("運算符不符合規則\n");
}
return res;
}
//列出10道題
void takeTest()
{
printf("開始答題,每道題10分,總共100分\n");
clock_t startTime;
startTime=clock();
int index;
int giveRes;
int num1;
int num2;
int score=0;
char signal;
for(index=0;index<CALC_NUM;index++)
{
srand((unsigned)time(NULL));
signal=getSignal();
num1=random(0,100);
num2=random(1,100);
printf("%d%c%d=",num1,signal,num2);
scanf("%d",&giveRes);
fflush(stdin);
if(getResult(num1,num2,signal)==giveRes)
{
printf("correct\n");
score+=10;
}
else
{
printf("wrong\n");
}
}
FILE *fp=fopen("score.txt","w");
fprintf(fp,"分數為%d",score);
fclose(fp);
printf("解10道題用了%lf秒\n",(double)(clock()- startTime)/CLOCKS_PER_SEC);
}
//檢測idNo是否合規則,合規則返回true
bool checkNo(char idNo[])
{
int index;
bool flag;
flag=true;
for(index=0;index<IDNO_LENGTH;index++)
{
if(index<2)
{
if(!isalpha(idNo[index]))
{
flag=false;
printf("ID no 不符合規則,重新輸入:");
break;
}
}
else
{
if(!isdigit(idNo[index]))
{
flag=false;
printf("ID no 不符合規則,重新輸入:");
break;
}
}
}
return flag;
}
C. 小學生考試c是多少分
60-70分
abcde(一般沒有e等級)等級的確定是由很多因素決定的,比如說地區、考卷的難度、考生成績的整體分布情況等等。
但是大多數等級區分如下:
a:100-85,,b:85-70,c:70-60,d:60分以下,沒有e等級;
語數外不是一百分制的情況下,其等級區分為:
a:120-100,b:100-85,c:85-70暢頂扳雇殖概幫誰爆京,d:70分以下,沒有e等級。
D. c語言小學生四則運算
int main()
{
double a=5.2,b=3.1;
printf("%lf %lf %lf %lf\n",a+b,a-b,a*b,a/b);
return 0;
}
E. 利用c語言編寫一個簡單的小學生測驗系統,功能要求如下。
#include "stdio.h"
#include "iostream"
#include "windows.h"
#define MAX 1000
char problems[MAX][100];
int answers[MAX];
bool flag[MAX] = {false};
int score;
int n;
void init()
{
score = 0;
FILE *fp = fopen("D:\\題庫.txt","r");//這里修改路徑
fscanf(fp,"%d",&n);
for(int i = 0;i < n;i++)
fscanf(fp,"%s%d",problems[i],&answers[i]);
fclose(fp);
}
void solve(int i,int k)
{
int ans = 0;
printf("第%d題(現在總分是%d分):\n",i,score);
for(int j = 0;j < 3;j++)
{
printf("%s=",problems[k]);
scanf("%d",&ans);
if(ans == answers[k])
{
if(j == 0)
score += 10;
else if(j == 1)
score += 7;
else
score += 5;
if(i != 10)
printf("正確!,下一題......\n");
return;
}
printf("- -,錯誤......\n");
}
}
void start()
{
int count = 0,t;
while(count != 10)
{
t = rand()%n;
if(flag[t])
continue;
flag[t] = true;
solve(count+1,t);
count++;
}
if(score < 60)
printf("TRY AGAIN\n");
else if(score < 70)
printf("PASS\n");
else if(score < 80)
printf("OK\n");
else if(score < 90)
printf("GOOD\n");
else
printf("SMART\n");
}
int main()
{
srand(GetTickCount());
init();
start();
system("pause");
}
題庫.txt
11
1+2 3
1+3 4
1+4 5
1+5 6
7-1 6
7-2 5
7-3 4
11-3 8
11-4 7
11-5 6
11-6 5
F. c語言小學生測驗
#include
#include
#include
int main(){
srand(time(NULL));
int a,b,c,score[10],trueValue,sum=0;
for(int i=0;i<10;i++){
for(a=rand()%51,b=rand()%51;a+b>50 || a+b50 || a-b<0; a=rand()%51,b=rand()%51){;}
c=rand()%3;
for(int j=0;j<3;j++){
if(c==1){
printf("%d:%d+%d=",i+1,a,b);
trueValue=a+b;
scanf("%d",&score[i]);
if(score[i]!=trueValue){
printf("答案錯誤,請重新輸入.\n");
score[i]=0;
}
else{
if(j==0){
score[i]=10;
}
else if(j==1){
score[i]=7;
}
else{
score[i]=5;
}
break;
}
}
else{
printf("%d:%d-%d=",i+1,a,b);
trueValue=a-b;
scanf("%d",&score[i]);
if(score[i]!=trueValue){
printf("答案錯誤,請重新輸入.\n");
score[i]=0;
}
else{
if(j==0){
score[i]=10;
}
else if(j==1){
score[i]=7;
}
else{
score[i]=5;
}
break;
}
}
}
if(score[i]==0){
printf("正確答案是:%d\n",trueValue);
}
sum=sum+score[i];
}
printf("你的成績是:%d\n",sum);
if(sum>90){
printf("SMART.\n");
}
else if(sum>=80){
printf("GOOD.\n");
}
else if(sum>=70){
printf("OK.\n");
}
else if(sum>=60){
printf("PASS.\n");
}
else{
printf("TRYAGAIN\n");
}
return 0;
}
G. 用C語言 給小學生出加法考試題
#include <stdlib.h>
#include <stdio.h>
int AddTest(int a,int b)
{
int answer;
printf("Please input the answer:");
scanf("%d",&answer);
if(answer==a+b){
printf("Right!\n");
return 1;}
else{
printf("Not correct!\n");
return 0;}
}
int main()
{
int i,j,k,m,sum=0,wsum=10;
for(k=0;k<10;k++){
i = rand()%10+1;
j = rand()%10+1;
printf("i=%d,j=%d\n",i,j);
m = AddTest(i,j);
sum+=m*10;
wsum-=m;
}
printf("The score is %d,and the wrong number is %d\n",sum,wsum);
return 0;
}
四則運算題可以產生隨機數之後按其%4+1的結果來控制內產生隨機的四種運算,其他地方容類似
H. C語言程序設計:小學生測驗
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void main()
{
int num=0,err=0; /* 答題數,錯誤數 */
while(1)
{
int a=0,b=0,d=0,c=0,i=0,result;
char sf[2]={'+','-'};
/* 出題 */
while(1)
{
a=rand()%51;
b=rand()%51;
d=rand()%2;
if(d==0)c=a+b;
else c=a-b;
if(c>=0 && c<=50)break;
}
printf("%d %c %d = \n",a,sf[d],b);
/* 回答 */
printf("輸入計算結果:\n");
while(1)
{
scanf("%d",&result);
i++;
if(result==c)
{
printf("回答正確!\n");
break;
}
else if(i<3)
{
printf("錯誤,請重新回答:\n");
}
else
{
err++;
break;
}
}
num++;
if(num==10)break;
}
printf("\n得分:%d 正確率:%d%\n",100-err*10,100-err*10);
getch();
}
I. 幫忙設計個小學生四則運算C語言程序
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int num=0,num1=0;
int m[1000][100];
char oper[4]={'+','-','*','/'};
int main()
{
int a,b,c,d,e,flag,i,j;
for(i=1;i<=1000;++i)
for(j=1;j<=i;++j)
if(i%j==0)
m[i][m[i][0]++]=j;
srand(time(0));
while(1)
{
system("cls");
printf("當前答題數:%d 正確數:%d 正確率:%.2lf%%\n",num,num1,num?num1*1.0/num*100:0);
flag=0;
c=rand()%4;
while(1)
{
flag=0;
if(c<3)
{
a=rand()%1000;b=rand()%1000;
}
else
{
a=rand()%1000;
b=rand()%m[a][0];
b=m[a][b];
}
switch(c)
{
case 0:
if(a+b<=1000)
flag=1,d=a+b;
break;
case 1:
if(a>=b)
flag=1,d=a-b;
break;
case 2:
if(a*b<=1000)
flag=1,d=a*b;
break;
case 3:
if(a%b==0)
flag=1,d=a/b;
break;
}
if(flag)
break;
}
printf("%d%c%d=?\n",a,oper[c],b);
num++;
scanf("%d",&e);
if(e==d)
{
printf("恭喜你回答正確!\n");
num1++;
}
else
{
printf("很遺憾,回答錯誤,正確答案是%d\n",d);
}
system("pause");
}
}
J. 小學生測驗+c語言代碼
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main(){
srand(time(NULL));
int a,b,c,score[10],trueValue,sum=0;
for(int i=0;i<10;i++){
for(a=rand()%51,b=rand()%51;a+b>50 || a+b<0 || a-b>50 || a-b<0; a=rand()%51,b=rand()%51){;}
c=rand()%3;
for(int j=0;j<3;j++){
if(c==1){
printf("%d:%d+%d=",i+1,a,b);
trueValue=a+b;
scanf("%d",&score[i]);
if(score[i]!=trueValue){
printf("答案錯誤,請重新輸入.\n");
score[i]=0;
}
else{
if(j==0){
score[i]=10;
}
else if(j==1){
score[i]=7;
}
else{
score[i]=5;
}
break;
}
}
else{
printf("%d:%d-%d=",i+1,a,b);
trueValue=a-b;
scanf("%d",&score[i]);
if(score[i]!=trueValue){
printf("答案錯誤,請重新輸入.\n");
score[i]=0;
}
else{
if(j==0){
score[i]=10;
}
else if(j==1){
score[i]=7;
}
else{
score[i]=5;
}
break;
}
}
}
if(score[i]==0){
printf("正確答案是:%d\n",trueValue);
}
sum=sum+score[i];
}
printf("你的成績是:%d\n",sum);
if(sum>90){
printf("SMART.\n");
}
else if(sum>=80){
printf("GOOD.\n");
}
else if(sum>=70){
printf("OK.\n");
}
else if(sum>=60){
printf("PASS.\n");
}
else{
printf("TRYAGAIN\n");
}
return 0;
}