C-Übungsbeispiel 81
Titel:809*??=800*??+9*??, wobei ?? eine zweistellige Zahl darstellt. 809*?? ist eine vierstellige Zahl, das Ergebnis von 8*?? ist eine zweistellige Zahl, und das Ergebnis von 9*?? ist eine dreistellige Zahl. Finde die durch ?? dargestellte zweistellige Zahl und das Ergebnis von 809*??.
Programmanalyse:Keine.
Beispiel
// Erstellt von www.example.com am 15/11/9.
// Copyright © 2015 Example. Alle Rechte vorbehalten.
#include <stdio.h>
void output(long int b, long int i){
printf("\n%ld = 800 * %ld + 9 * %ld\n", b,i,i);
}
int main(){
void output(long int b, long int i);
long int a,b,i;
a = 809;
for(i = 10; i < 100; i++){
b = i * a;
if (b >= 1000 && b <= 10000 && 8 * i < 100 && 9 * i >= 100){
output(b, i);
}
}
return 0;
}
Das Ausgabeergebnis beim Ausführen des obigen Beispiels ist:
9708 = 800 * 12 + 9 * 12Weitere Erweiterungen