본문 바로가기
프로그래밍/C_정보올림피아드 Language_Coder

CODE 125 반복제어문1 - 형성평가 1~5

by Royal! 2020. 9. 3.
728x90
반응형

 

#include<stdio.h>
int main(void){
   int a=0 , b=1;
   scanf("%d",&a);
   while(b<=a){
   printf("%d",b++);
  }

}

정답은 틀렸다고 나옵니다...

 

CODE 127

#include<stdio.h>

int main(void){
int score, sum, b;
score=sum=b=0;

do{
scanf("%d",&score);
if(score>=0 && score<=100)
{
sum+=score;
b++;
}
else
{
break;
}
}while(score<101);
printf("sum : %d\navg : %.1f",sum,(float)sum/b);

return 0; 
}

CODE 128

#include<stdio.h>

int main(void){
int a,b;
a=1; b=0;

do{
scanf("%d",&a);
if((a%3)!=0 && (a%5)!=0)  // AND연산자 말고 OR연산자로 해도 상관 없을것 같다.
{
b++; 
}
}while(a!=0);
printf("%d",b);
}

 

CODE 129

#include "stdio.h"

int main(void)
{
int base,height,width;
char c='y';
base = height = width = 0;
do{

printf("Base = ");
scanf("%d",&base);
printf("Height = ");
scanf("%d",&height);
printf("Triangle width = %.1f\n",(float)base*height/2);
printf("Continue? ");
scanf(" %c",&c);
}while(c=='y'|| c=='Y');

return 0;
}

 

728x90
반응형