CCF 202012-1 期末预测之安全指数 C语言代码(100分)

CCF 202012-1 期末预测之安全指数 C语言代码(100分)

问题描述

解题思路

硬解法。

详细代码

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

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
typedef struct {
    
    
	int flag;
	int score;
}Course;
int main(int argc, char *argv[]) {
    
    
	int n,sum=0,i;
	scanf("%d",&n);
	Course course[n];
	for(i=0;i<n;i++){
    
    
		scanf("%d %d",&course[i].flag,&course[i].score);
	}
	for(i=0;i<n;i++){
    
    
		
		sum+=course[i].flag*course[i].score;
	}
	if(sum<=0){
    
    
		printf("0");
	}else{
    
    
			printf("%d",sum	);
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/Houstox/article/details/113806001