Beecrowd Problem 1121-1140 Solve by C
Beecrowd Problem 1121
#include <stdio.h> int main(){ int n; int x, y, aux; int soma; while(1){ scanf("%d%d",&x,&y); if(x <= 0) break; if(y <= 0) break; if(x > y){ aux = x; x = y; y = aux; } soma = 0; for(int i = x; i <= y; i++){ printf("%d ",i); soma += i; } printf("Sum=%d\n",soma); } return 0; }
Beecrowd Problem 1122
Beecrowd Problem 1123
Beecrowd Problem 1124
Beecrowd Problem 1125
Beecrowd Problem 1126
Beecrowd Problem 1127
Beecrowd Problem 1128
Beecrowd Problem 1129
Beecrowd Problem 1130
Beecrowd Problem 1131
#include <stdio.h> int main() { int a,b,c=0,d=0,e=0,f,g,h,i,j=0,k=0,l=0; while(1) { scanf ("%d%d", &a, &b); if(a>b) l++; if(a<b) k++; if(a==b) j++; c+=a; d+=b; e++; printf("Novo grenal (1-sim 2-nao)\n"); scanf("%d",&f); if(f==1) continue; if(f==2) break; } printf("%d grenais\n",e); printf("Inter:%d\n",l); printf("Gremio:%d\n",k); printf("Empates:%d\n",j); if(l>k) printf("Inter venceu mais\n"); if(l<k) printf("Gremio venceu mais\n"); if(k==l) printf("Nao houve vencedor\n"); return 0; }
Beecrowd Problem 1112
Beecrowd Problem 1113
#include<stdio.h> int main() { int x,y; while(1) { scanf("%d %d",&x,&y); if(x==y) break; else { if(x<y) { printf("Crescente\n"); } else { printf("Decrescente\n"); } } } return 0; }
Beecrowd Problem 1114
#include<stdio.h> int main() { int n; while(1) { scanf("%d",&n); if(n==2002) { printf("Acesso Permitido\n"); break; } else { printf("Senha Invalida\n"); } } return 0; }
Beecrowd Problem 1115
#include<stdio.h> int main() { int i,j; for(i=1,j=60;i<15,j>=0;i+=3,j-=5){ printf("I=%d J=%d\n",i,j); } }
Beecrowd Problem 1116
#include <stdio.h>
int main()
{
int n, i;
float x, y;
scanf(“%d”, &n);
for(i = 0; i < n; ++i)
{
scanf(“%f %f”, &x, &y);
if(y == 0)
{
printf(“divisao impossivel\n”);
}
else
{
printf(“%.1f\n”, (x/y) );
}
}
return 0;
}
Beecrowd Problem 1117
#include <stdio.h> int main() { double a,b,c=0,d=0; while(1) { if(d==2) break; scanf("%lf", &a); if(a>=0 && a<=10) { d++; c+=a; } else printf("nota invalida\n"); } b=c/2.00; printf("media = %.2lf\n", b); return 0; }
Beecrowd Problem 1118
#include<stdio.h> int main() { float n,s,p,k; s = p = k = 0; while(1) { scanf("%f",&n); if(n < 0.0 || n > 10.0) printf("nota invalida\n"); else { s += n; p++; if(p==2) { s/=2; printf("media = %.2lf\n",s); printf("novo calculo (1-sim 2-nao)\n"); while(1) { scanf("%f",&n); if((int)n==1) { s = p = 0; k=1; break; } else if((int)n==2) return 0; else printf("novo calculo (1-sim 2-nao)\n"); } } } } return 0; }
Beecrowd Problem 1119
#include<stdio.h> int main(){ int n; int x, y, aux; int soma; scanf("%d",&n); while(1){ if(n == 0) break; scanf("%d%d",&x,&y); if(x > y){ aux = x; x = y; y = aux; } soma = 0; for(int i = x+1; i < y; i++){ if(i%2 != 0) soma += i; } printf("%d\n",soma); n--; } return 0; }
Beecrowd Problem 1120
Leave a Reply