用c语言编写输入一学生成绩,和相应优秀,良好,不及格信息

如题所述

#include <stdio.h>
#include <stdlib.h>
#include "windows.h"

int main(int argc, char *argv[]) 
{
    int cj; 
    do{
        system("cls");
        printf("请输入成绩:");
        scanf("%d",&cj);
        if(cj>0 && cj<101)
        {
           if(cj>=90 && cj<=100)
             printf("\n优秀\n");
            else if(cj>=70 && cj<=89)
             printf("\n良好\n");
            else if(cj>=60 && cj<=69)
         printf("\n及格\n");
            else if(cj>=0 && cj<=59)
            {
             SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED);
             printf("\n不及格\n");
             SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
            }
        }
        else
        {
            printf("\nerror\n");
        }
        printf("\n如果要继续请按y\n");
        fflush(stdin);
        cj=_getch();
    }
    while(cj=='y');
    return 0;
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-12-05
#include<stdio.h>
void main() { float s;
  scanf("%f",&s);
  if ( s>=90 ) printf("优秀\n");
  else if ( s>=85 ) printf("良好\n");
  else if ( s>=60 ) printf("合格\n");
  else printf("不及格\n");
}