98 942
Assignments Done
98.8%
Successfully Done
In May 2021

# Answer to Question #24468 in C for gene

Question #24468
Write a c program that lets the user input something like the example below only using scanf():
c 1
c 2
c 3
c 4
a 1 2 1900
a 1 3 1950
a 1 4 1400
a 2 3 150
a 2 4 3100
a 3 4 3150

And after the user is finished use printf() to output the following sentence example:
The tour 2 1 3 4 2 costs 10100.
1
2013-02-19T09:03:07-0500
#include <stdio.h>int main(){
for(inti = 0; i < 100; i++){
for(intj = 0; j < 100; j++){
}
}
charch;
intd;
while(true){
scanf("%c",&ch);
if(ch== 'a')
break;
scanf("%d",&d);
getchar();
}
inti, j, distance;
scanf("%d%d %d", &i, &j, &distance);
getchar();
for(intk = 1; k < d*(d - 1)/2; k ++){
scanf("%c%d %d %d", &ch, &i, &j, &distance);
getchar();
}
inttour[] = {2, 1, 3, 4, 2};
intprice = 0;
printf("Thetour ");
printf("%d", tour[0]);
for(inti = 0; i < 4; i ++){
printf("%d", tour[i+1]);
}
printf("costs%d.", price);
getchar();
return0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!