Wednesday 13 January 2016

Solution of URI 1098 :: Sequence IJ 4


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    double a,b,c=1,d=3,e,f;
    int x;
    for(a=0; a<=1.9; a=a+.2)
    {
        for(b=1.0; b<=3.0; b++)
        {
            e=b+a;
            if(a==0.0||a==1.0) printf("I=%.0lf J=%.0lf",a,e);
            else if(e==3.0||e==4.0||e==5.0) printf("I=%.0lf J=%.0lf",a,e);
            else printf("I=%.1lf J=%.1lf",a,e);
            printf("\n");
        }
    }
    for(x=3; x<=5; x++) printf("I=2 J=%d\n",x);
    return 0;
}

8 comments:

  1. int x=(int) 2.0=1
    How it possible ?
    It occurs at my code can you described me ?
    Thank you

    #include
    using namespace std;
    int main(){
    double i,j;
    int cmi,cmj;
    for(i=0;i<=2.0;i=i+.2){
    for(j=i+1;j<=i+3;j=j+1){
    cmi=(int) i;
    cmj=(int) j;

    // printf("%d %.1lf\n",cmi,i);


    if(cmi==i)
    printf("I=%d J=%d\n",cmi,cmj);
    else if(cmj==j)
    printf("I=%d J=%d\n",cmi+1,cmj);
    else
    printf("I=%.1lf J=%.1lf\n",i,j);

    }
    }
    // printf("%lf %d",i,cmj);
    return 0;
    }

    ReplyDelete
  2. #include
    using namespace std;

    int main()
    {
    for(float I = 0; I <= 2.2; I += 0.2){
    for(float J = 1; J <= 3.0; J++){
    cout << "I=" << I << " " << "J=" << I+J << endl;
    }
    }

    return 0;
    }

    ReplyDelete
  3. Need help this problem else if part not work. I see 1.6 up any condition not work why .....
    #include

    int main()
    {
    double i,j,k;

    for(i=0;i<=2.0;i+=0.2)
    {
    for(j=1.0;j<=3.0;j++)
    {
    if(i==0 || i==1)
    {
    printf("I=%.0lf J=%.0lf\n",i,i+j);
    }
    else if(i==2)
    printf("I=%.0lf J=%.0lf\n",i,i+j);
    else{
    printf("I=%.1lf J=%.1lf\n",i,i+j);
    }

    }
    }
    return 0;
    }

    ReplyDelete
  4. #include
    using namespace std;
    int main()
    {
    double a,b;
    for(a=0;a<2;a+=.2){
    for(b=1;b<=3;b++){
    cout<<"I="<<a<<" "<<"J="<<b+a<<endl;
    }
    }
    }

    ReplyDelete
  5. #include
    int main()
    {
    float I,J,a=1.0,b;
    for(I=0;I<=2.2;I=I+0.2)
    {
    for(b=1.0,J=a;b<=3.0;b++,J++)

    printf("I=%.1f J=%.1f\n",I,J);
    a+=.2;
    }
    return 0;
    }

    it shows 5% error. but i couldn't find the wrong. please help me

    ReplyDelete
  6. #include
    int main ()
    {

    double i,j,k;

    for(i=0;i<=2.0;i+=0.2)
    {
    for(j=1.0;j<=3.0;j++)
    {
    if(i==0 || i==1)
    {
    printf("I=%.0lf J=%.0lf\n",i,i+j);
    }
    else if(i==2)
    printf("I=%.0lf J=%.0lf\n",i,i+j);
    else{
    printf("I=%.1lf J=%.1lf\n",i,i+j);
    }

    }
    }
    return 0;
    } it shows 5% wrong.please help me.

    ReplyDelete
  7. public class prob_1098 {

    public static void main(String[] args) {
    float i, j, k = 0;
    int l, x=2;
    for (i = 0; i <= 2; i += 0.2, k += 0.2) {
    for (j = 1 + k; j <= 3 + k; j++) {
    if(i==0.0 || i==1.0){
    System.out.printf("I=%.0f J=%.0f\n", i, j);
    continue;
    }
    System.out.printf("I=%.1f J=%.1f\n", i, j);
    }
    }
    for(l=3; l<=5; l++){
    System.out.printf("I=%d J=%d\n",x,l);
    }
    }
    }

    ReplyDelete

  8. for (float i = 0,j=1; i <= 2.1;i+=.2,j+=.2)
    {
    /* code */
    cout<<"I="<<i<<" "<<"J="<<j<<endl;
    cout<<"I="<<i<<" "<<"J="<<j+1<<endl;
    cout<<"I="<<i<<" "<<"J="<<j+2<<endl;

    }

    ReplyDelete

Note: only a member of this blog may post a comment.